IOT

Smart Vehicle using Arduino Uno

IoT or the internet of things is characterized as a forthcoming innovation that empowers us to control equipment gadgets through the Internet. Homes of the next generation will become more and more self-controlled and mechanized because of the solace it gives, particularly when utilized in a private home.  

Shoes, watches, and eyewear are becoming smarter all around us. You may even have read the news about smart cars in the papers. The same goes for our attempt to use Arduino to build a smart vehicle prototype. Let’s start with the portion of developing our smart automobile.

INPUT PERIPHERALS:

  • Potentiometer – For Controlling the speed of our vehicle
  • L293D Motor driver – To drive the motor from Arduino using Arduino signals
  • Power Supply – Supply to our entire project
  • Regulator (L7805CV) – Regulating the input voltage to project
  • LDR – Detect the condition of the drive (Day or night)
  • Button – Turn ON/OFF vehicle

OUTPUT PERIPHERALS:

  • Ultrasonic Sensor – To detect the obstacles on the road
  • Buzzer – Sounding element
  • DC Motor – Drive for the vehicle
  • LED – Indicator

SCHEMATIC DIAGRAM OF SMART VEHICLE:

WORKING EXPLANATION:

The smart vehicle can only be started by pushing a button, and a blue LED shows whether it is on or off. The ultrasonic sensor and DC motor are triggered when the button is pressed. Therefore, based on the controller’s chosen speed, the vehicle begins to move.

The LDR is also used to determine whether it is day or night. Additionally, the driver of this car can simply take control. When a roadie is identified, the controller for the ultrasonic sensor will notify the user. This will assist the user in preventing any mishaps.

Your vehicle will continuously burn fuel if it is stopped in traffic. To prevent this, set a timer to run for 10 seconds; if there is no motion detected during that period, the vehicle will be turned off. Again, hitting the button will start the engine.

Be careful when adjusting the photoresistor’s value. To accomplish this, you must first measure the sensor value both during the day and at night, and then determine the best value for your project.

CODE:

#define trig 4#define echo 3const int buttonPin = 8; int buttonState=0; int c=0,s,n;int duration,distance; //declaration of the variablesint photocellPin = A4; // the cell and 10K pulldown are connected to a4int photocellReading; // the analog reading from the sensor dividerint LEDpin = 10; // connect LED to pin 10 (PWM pin)

void setup() { Serial.begin(9600); pinMode(trig,OUTPUT); pinMode(0,OUTPUT); pinMode(echo,INPUT); pinMode(8, INPUT); pinMode(6,OUTPUT); pinMode(5,OUTPUT); pinMode(A2,INPUT); pinMode(9,OUTPUT);
}
#define trig 4
#define echo 3
const int buttonPin = 8;
int buttonState=0;
int c=0,s,n;
int duration,distance; //declaration of the variables
int photocellPin = A4; // the cell and 10K pulldown are connected to a4
int photocellReading; // the analog reading from the sensor divider
int LEDpin = 10; // connect LED to pin 10 (PWM pin)


void setup()
{

Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(0,OUTPUT);
pinMode(echo,INPUT);
pinMode(8, INPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(A2,INPUT);
pinMode(9,OUTPUT);

}

void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState==HIGH)
{
c=1;


}
stop:
if(c==1)
{
digitalWrite(9,LOW);
int val = analogRead(A2);
val = map(val, 0, 1023, 0, 255);
photocellReading=analogRead(A4);
if(photocellReading>580)
{
digitalWrite(10,HIGH);
}
else
{
digitalWrite(10,LOW);

}
for(s=0;val==0;s++)
{
int val = analogRead(A2);
val = map(val, 0, 1023, 0, 255);
// Serial.println(val);
if(val!=0)
{
break;
}
delay(1000);
if(s==10)
{
c=0;
goto stop;
}
}
analogWrite(6,val);
digitalWrite(5,LOW);
ultra();
if(distance<40||distance>150)
{
digitalWrite(0, HIGH); // turn the buzzer on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(0, LOW); // turn the buzzer off by making the voltage LOW
delay(1000);
for(n=val;n>180;)
{
n=n-20;
//Serial.println(n);
analogWrite(6,n);
delay(1000);
digitalWrite(5,LOW);
ultra();
}
if(n>160)
{
analogWrite(6,170);
delay(2000);
}


}
else
{
ultra();
}
}
else
{
digitalWrite(9,HIGH);
}
}
void ultra()
{
digitalWrite(trig,LOW); //set the trig pin to low
delayMicroseconds(2000); //pause to let signal settle
digitalWrite(trig,HIGH); //set the trig pin to high
delayMicroseconds(10); //pause signal at high state
digitalWrite(trig,LOW); //set the trig pin to low
duration = pulseIn(echo,HIGH); //measure time at echo pin in microseconds
distance = duration/58; //converting the time in distance(centimeters)
Serial.println(distance);
}

Conclusion
I hope all of you understand how to design a Smart Vehicle System using Arduino. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.