0% found this document useful (0 votes)
11 views4 pages

Lesson 7 - Left - and - Right

Uploaded by

midnightbrb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Lesson 7 - Left - and - Right

Uploaded by

midnightbrb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Lesson 7 – Left

and right

 OUT1 and OUT2 is connected to left motor


 OUT3 and OUT4 is connected to right motor
 IN1 is connected to Pin 5
 IN2 is connected to Pin 6
 IN3 is connected to Pin 9
 IN4 is connected to Pin 10
 VCC is connected to Vin, and
 GND is connected to GND on the Arduino
board
To control your wheels, you can
add a switch from the GND to
the EEP pin. When the switch is
OFF the car will move. When
the slEEP pin is on, the car will
sleep.
Adding a Switch
int IN1=5; }

Turning int IN2=6;


int IN3=9; //left: //stop:
Run the program on the int IN4=10; digitalWrite(IN1,LOW); digitalWrite(IN1,LOW);
right and experiment digitalWrite(IN2,HIGH); digitalWrite(IN2,LOW);
with turns and delays void setup() {
digitalWrite(IN3,LOW); digitalWrite(IN3,LOW);
pinMode(IN1,OUTPUT); digitalWrite(IN4,LOW);
digitalWrite(IN4,HIGH);
pinMode(IN2,OUTPUT); delay(2000);
delay(150);
pinMode(IN3,OUTPUT);
//right:
pinMode(IN4,OUTPUT); //stop:
digitalWrite(IN1,HIGH)
} digitalWrite(IN1,LOW); ;
void loop() { digitalWrite(IN2,LOW); digitalWrite(IN2,LOW);

//forward: digitalWrite(IN3,LOW); digitalWrite(IN3,HIGH)


;
digitalWrite(IN1,HIGH); digitalWrite(IN4,LOW);
digitalWrite(IN4,LOW);
digitalWrite(IN2,LOW); delay(2000);
delay(150);
digitalWrite(IN3,LOW);
//forward:
digitalWrite(IN4,HIGH); //stop:
digitalWrite(IN1,HIGH); digitalWrite(IN1,LOW);
delay(500);
digitalWrite(IN2,LOW); digitalWrite(IN2,LOW);
//stop:
digitalWrite(IN3,LOW); digitalWrite(IN3,LOW);
digitalWrite(IN1,LOW);
digitalWrite(IN4,HIGH); digitalWrite(IN4,LOW);
digitalWrite(IN2,LOW);
delay(500); delay(2000);
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW); while (1==1) {}
delay(2000);
Assessment

• Plot a path to 1 and programme your robot to navigate through it.

• Forward 50 cm
• 90 degree turn right
• Forward 50 cm
• Turn right 90 degrees
• Forward 40 cm
• Turn left 90 degrees
• Forward 20 cm
• Turn left 90 degrees
• Forward 15 cm

You might also like