Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

IOT

AUTOMOTIVE
LAB
DA4
BY

P.SAI CHARAN

18BIS0071

L43+L44
AIM
Objective: Create a scenario of autonomous vehicles basic functionalities like moving
forward, backward, left, right and stop. This task utilizes the 4 DC motors (2 forward
and 2 backward) to realize the wheels of the autonomous vehicles and 5 Push button.
Push button I: Used to make the AV to move Forward
 Push button II: Used to make the AV to move Backward
 Push button III: Used to make the AV to move Left
 Push button IV: Used to make the AV to move Right
 Push button V: Used to make the AV to move Stop
CIRCUIT DIAGRAM:
CODE:
enum{Stop, MoveForward, MoveBackward, MoveLeft, MoveRight};

int in1A = 11;


int in2A = 10;
int in1B = 9;
int in2B = 8;

int current = Stop;


int cmd;

void setup()
{
Serial.begin(9600);
pinMode(in1A,OUTPUT);
pinMode(in2A,OUTPUT);
pinMode(in1B,OUTPUT);
pinMode(in2B,OUTPUT);

void loop()
{

switch(current)
{
case Stop:
digitalWrite(in1A,LOW);
digitalWrite(in2A,LOW);
digitalWrite(in1B,LOW);
digitalWrite(in2B,LOW);

if(Serial.available()>0)
cmd = Serial.read();

if (cmd == 'F')
current = MoveForward;

if (cmd == 'B')
current = MoveBackward;

if (cmd == 'R')
current = MoveRight;
if (cmd == 'L')
current = MoveLeft;
break;

case MoveForward:
digitalWrite(in1A,HIGH);
digitalWrite(in2A,LOW);
digitalWrite(in1B,HIGH);
digitalWrite(in2B,LOW);

if(Serial.available()>0)
cmd = Serial.read();

if (cmd == 'S')
current = Stop;

if (cmd == 'B')
current = MoveBackward;

if (cmd == 'R')
current = MoveRight;

if (cmd == 'L')
current = MoveLeft;
break;

case MoveBackward:
digitalWrite(in1A,LOW);
digitalWrite(in2A,HIGH);
digitalWrite(in1B,LOW);
digitalWrite(in2B,HIGH);

if(Serial.available()>0)
cmd = Serial.read();

if (cmd == 'F')
current = MoveForward;

if (cmd == 'S')
current = Stop;

if (cmd == 'R')
current = MoveRight;

if (cmd == 'L')
current = MoveLeft;
break;

case MoveLeft:
digitalWrite(in1A,HIGH);
digitalWrite(in2A,LOW);
digitalWrite(in1B,LOW);
digitalWrite(in2B,HIGH);

if(Serial.available()>0)
cmd = Serial.read();

if (cmd == 'F')
current = MoveForward;

if (cmd == 'B')
current = MoveBackward;

if (cmd == 'R')
current = MoveRight;

if (cmd == 'S')
current = Stop;
break;

case MoveRight:
digitalWrite(in1A,LOW);
digitalWrite(in2A,HIGH);
digitalWrite(in1B,HIGH);
digitalWrite(in2B,LOW);

if(Serial.available()>0)
cmd = Serial.read();

if (cmd == 'F')
current = MoveForward;

if (cmd == 'B')
current = MoveBackward;

if (cmd == 'S')
current = Stop;

if (cmd == 'L')
current = MoveLeft;
break;
}
}
RESULTS:
CONCLUSION:

We have successfully designed a independent maneuvare system that allows you to


control front and back tires independently.

You might also like