Robotics PPT Grade 6 (2)
Robotics PPT Grade 6 (2)
Robotics PPT Grade 6 (2)
ROBOTICS
01 MICROCONTROLLER
Arduino
15
17 16
14
1 13
12
4
3 11
5
8 10
6
9
7
2
1 Power USB
Arduino board can be powered by using the USB cable from your
computer. You only need to connect the USB cable to the USB connection
(1).
3 Voltage Regulator
The voltage regulator controls the voltage given to the Arduino board
and stabilises the DC voltages used by the processor and other elements.
3
4 Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. Arduino
calculates time using the crystal oscillator. The number printed on top
of the Arduino crystal is 16.000H9H. It tells us that the frequency is
16,000,000 Hertz or 16 MHz
You can reset your Arduino board, i.e., start your program from the
beginning. You can reset the UNO board in two ways. First, by using
the reset button (17) on the board. Second, connect an external reset
button to the Arduino pin labelled RESET (5).
4
• 5V (7) − Supply 5 output volt
• Most of the components used with the Arduino board work fine with
3.3 volts and 5 volts.
• GND (8)(Ground) − Several GND pins are on the Arduino to give ground
to the circuit.
• Vin (9) − This pin also can be used to power the Arduino board from
an external power source, like the AC mains power supply.
10 Analog pins
The Arduino UNO board has six analog input pins A0 through A5.
These pins can read the signal from an analog sensor like the humidity
or temperature sensor and convert it into a digital value that the
microprocessor can read.
5
11 Main microcontroller
Each Arduino board has its microcontroller (11). You can assume it is
the brain of your board. The Arduino’s main IC (integrated circuit) is
slightly different from board to board.
12 ICSP pin
This LED should light up when you plug your Arduino into a power source
to indicate that your board is powered up correctly. If this light does
not turn on, the connection is wrong.
6
14 TX and RX LEDs
15 Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide
PWM (Pulse Width Modulation) output. These pins can be configured
to work as digital input pins to read logic values (0 or 1) or as digital
output pins to drive different modules like LEDs, relays, etc. The pins
labelled “~” can be used to generate PWM.
16 AREF
AREF stands for Analog Reference. It is sometimes used to set an
external reference voltage (between 0 and 5 Volts) as the upper limit
for the analog input pins.
7
Activity 1.1 LED Blinking using Arduino
Steps
Step 1: T
ake an Arduino. Step 2: Take a Breadboard.
8
Steps
Step 3: T
ake a LED and place
it on breadboard.
Step 4: C
onnect LED with
Arduino Uno as
shown in the figure.
9
Steps
Procedure:
1. C
onnect arduino to your laptop/desktop using arduino cable.
2. O
pen arduino IDE.
o to File > New Sketch > Write the Code.
3. G
o to Tools > Board > Select Arduino Uno.
4. G
o to Tools > Port > Select COM port.
5. G
6. C
lick on the verify option.
7. Click on the upload option.
Code:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(4, OUTPUT);
10
Steps
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Output:
11
Activity 1.2 Control LED with Serial Monitor
Components Required
Components Qty Components Qty
Steps
Step 1: C
onnect the longer leg of
the LED (the anode) through
a resistor to pin 13 of the
Arduino and the shorter leg
(the cathode) to ground.
12
Steps
Code:
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600); //set baud rate
}
void loop()
{
if (Serial.available() > 0) {
int state = Serial.read();
if (state == ‘1’) {
digitalWrite(13, HIGH);
}
else if (state == ‘0’) {
digitalWrite(13, LOW);
13
}
}
}
Output:
Once you upload the sketch to the Arduino board. Open the Serial
Monitor in the Arduino IDE. Make sure the baud rate is set to 9600.
In the Serial Monitor, type “1” and press Enter to turn on the LED.
Type “0” and press Enter to turn it off. You should see the LED turn
on and off in response to your input.
Challenge
14
02 MOTOR AND MOTOR DRIVERS
Motor Driver Module
16
BO Motor
17
Activity 2.1 Control the speed and direction of the motor
Steps
Step 1: C
onnect the Motor and
motor driver module with
Arduino as shown below.
Procedure:
1.Connect arduino to your laptop/desktop using arduino cable.
2. Connect motor and motor driver as shown in the figure.
18
Steps
Code:
const int pwm = 2 ;
const int in_1 = 9 ;
const int in_2 = 10 ;
void setup()
{
pinMode(pwm,OUTPUT) ;
19
Steps
pinMode(in_1,OUTPUT) ;
pinMode(in_2,OUTPUT) ;
}
void loop()
{
//For Clock wise motion , in_1 = High , in_2 = Low
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
analogWrite(pwm,255) ;
20
Steps
delay(1000) ;
//For brake
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;
delay(1000) ;
}
Output: The motor will run first in the clockwise (CW) direction for 3
seconds and then counter-clockwise (CCW) for 3 seconds.
Activity 2.2 Bot Assemble
Steps
Step 1: T
ake the MDF cuttout design given in the kit
22
Steps
Step 2: S
eparate all the parts from the chassis sheet.
23
Steps
Step 3: T
ake two motor clamps and lock clamps along with the chassis
as shown in image.
24
Steps
• Insert the motor clamps to the motor slots on chassis from bottom
to the top as shown in the image.
• Turn over the chassis to the top and insert the lock clamps to motor
clamp as shown in the figure.
25
Steps
Step 4: T
ake clamps, motors, M3x30 nuts and bolts.
26
Steps
Step 5: T
ake a motor and attach to the bottom side of the chassis,
add a motor side support clamp holder and connect it using
nuts and bolts, allen key as shown in image.
27
Chasis Assembly
28
29
Steps
Step 1: T
ake a MDF sheet of robotic chassis.
30
Steps
Step 2: S
eparate all the parts from the chassis sheet.
31
Steps
Step 3: T
ake two motor clamps and lock clamps along with the chassis
as shown in image.
32
Steps
• Insert the motor clamps to the motor slots on chassis from bottom
to the top as shown in the image.
• Turn over the chassis to the top and insert the lock clamps to motor
clamp as shown in the figure.
33
Steps
Step 4: T
ake clamps, motors, M3x30 nuts and bolts.
34
Steps
Step 5: T
ake a motor and attach to the bottom side of the chassis,
add a motor side support clamp holder and connect it using
nuts and bolts, allen key as shown in image.
35
Steps
Step 6: S
imilarly, attach the 2nd motor to the bottom side of the
chassis as shown in the image.
36
Steps
Step 7: N
ow take caster wheels, nuts and bolts, hex spacers and
Attach caster wheel on the bottom side of the chassis using
bolts and allen key as shown in image.
37
Steps
Step 8: N
ow take two wheels and fix it with motor shaft by aligning
properly and by press fit.
38
Steps
Step 9: T
ake an arduino board, nuts and bolts and attach it on the
top of the chassis with the help of nuts and bolts and allen
key as shown in image.
39
Steps
Step 10: T
ake the motor driver module, nuts and bolts and Attach it
on the top of the chassis using nuts and bolts and allen key
as shown in image.
40
Steps
Step 11: F
rom the down side of the chassis put motor wires on the
top side through holes and connect it to the motor driver
module using screwdriver as shown in below image.
41
Steps
Step 12: T
ake the cell holder, double sided tape and Attach it on the
bottom side of the chassis using double sided tape as shown
in image.
42
Steps
Step 13: C
onnect cell holder wires to the motor driver module as per
given details.
43
Steps
Step 14: T
ake another one red and black(you can take any coloured
wire) male to male wire and connect it to the motor driver
module.
44
Steps
Step 15: C
onnect motor driver module red and black wires to the
arduino board as per given details.
45
Steps
Step 16:
Take 4 male to
female wires and
connect it to the
motor driver module
input pins.
46
Steps
Step 17: T
ake 4 cell batteries and put them inside the cell holder.
47
Steps
Step 18: T
ake a wing with a holder and attach it on the chassis as
shown in below image.
Step 19: N
ow turn ON the switch which is present on Cell holder.
48
Steps
Code:
#define MLa 8 //left motor 1st pin
#define MLb 9 //left motor 2nd pin
#define MRa 10 //right motor 1st pin
#define MRb 11 //right motor 2nd pin
void setup() {
pinMode(MLa, OUTPUT);
pinMode(MLb, OUTPUT);
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
}
void loop() {
//stop both the motors//
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
49
Steps
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay(1000); //wait for 1 second// //Rotate both Motors in Forward Direction//
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
delay(2000); //wait for 2 second// //Rotate both Motors in Backward Direction//
digitalWrite(MLa, LOW);
digitalWrite(MLb, HIGH);
digitalWrite(MRa, LOW);
digitalWrite(MRb, HIGH);
delay(2000); //wait for 2 second// //Rotate robot in right direction
digitalWrite(MLa, HIGH); //Rotate left motor in fwd direction
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW); //Rotate right motor in back direction
50
Steps
digitalWrite(MRb, HIGH);
delay(2000); //wait for 2 second// //Rotate robot in left direction
digitalWrite(MLa, LOW); //Rotate left motor in fwd direction
digitalWrite(MLb, HIGH);
digitalWrite(MRa, HIGH); //Rotate right motor in back direction
digitalWrite(MRb, LOW);
delay(2000); //wait for 2 second//
}
Sets `MLa` to `LOW` and `MLb` to `HIGH` (left motor backward) and
`MRa` to ‘HIGH` and `MRb` to `LOW` (right motor forward) to turn the
robot left and waits for 2 Seconds.
51
03 SENSORS
52
IR Receiver
53
IR Remote
54
Activity 3.1 Motor control using IR remote
Steps
Step 1: T
ake an Arduino. Step 2: Take IR receiver and connect
as shown in diagram.
55
Steps
Step 4: T
ake an IR remote.
56
Steps
57
Steps
58
Steps
Procedure:
1. Connect arduino to your laptop/desktop using arduino cable.
2. Connect IR receiver as shown in the figure.
3. Connect motor driver module and BO motor as shown in figure.
4. Open arduino IDE.
5. Go to File > New sketch > Write code.
6. Go to Tools > Board > Select Arduino Uno.
7. Go to Tools > Port > Select COM port.
8. Click on the verify option.
9. Click on the upload option.
10. C
lick the shown buttons to
move the motor to left and right.
59
Steps
Output: You can see the robot start moving when you press the
buttons shown above. You can press the left button to turn
the robot to the left, and vice versa for a right turn.
Code:
#include <IRremote.h>
void setup() {
IrReceiver.begin(2);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
60
Steps
void loop() {
if (IrReceiver.decode()) {
if (IrReceiver.decodedIRData.decodedRawData == 0xFB04BF00) {
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
else if (IrReceiver.decodedIRData.decodedRawData == 0xF906BF00) {
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
}
else {
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
61
Steps
delay(1000);
IrReceiver.resume();
}
delay(10);
}
62
63
64
65
66
IR Sensor
VCC
GND
Out
67
Activity 3.2 Edge Avoiding Robot
Components Required
Components Qty Components Qty
BO wheel 2 IR remote 1
Caster wheel 1 AA batteries 4
68
Circuit Diagram:
69
Steps
Procedure:
1. I f you performed the previous Build a Motion Robot activity, then
keep the chassis model as it is because we are going to use that
model in this activity as it is. We are going to add only an IR sensor
on that model.
2. F irst remove batteries from the cell holder/turn off the switch on
the cell holder.
3. C onnect an arduino board to your laptop/desktop using an arduino
cable.
4. Open Arduino IDE.
5. G o to File > Examples > Sparklebox_code > Select build_a_Edge_
Avoiding_Robot_using_IR.
6. Go to Tools > Board > Select Arduino Uno.
70
Steps
Code:
#define MLa 8 //left motor 1st pin
#define MLb 9 //left motor 2nd pin
#define MRa 10 //right motor 1st pin
#define MRb 11 //right motor 2nd pin
#define Sensor 2
void setup()
{
pinMode(Sensor, INPUT);// declaring sensor pin as input pin for Arduino
pinMode(MLa, OUTPUT);// declaring Motors pin as output pin
pinMode(MLb, OUTPUT);
71
Steps
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int Sensorin=digitalRead(Sensor);
Serial.println(Sensorin);
delay(100);
if ( Sensorin == LOW) // applying condition
{//forward
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
72
Steps
}
else{//Stop
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay(300);
//backward
digitalWrite(MLa, LOW);
digitalWrite(MLb, HIGH);
digitalWrite(MRa, LOW);
digitalWrite(MRb, HIGH);
delay(500);
//Stop
digitalWrite(MLa, LOW);
73
Steps
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay(300);
//Rightturn
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay(500);
}
}
74
Procedure to assemble the edge avoiding robot using IR
Step 1: T
ake sensor holders, constructed motion robot.
75
Procedure to assemble the edge avoiding robot using IR
Step 2: A
ttach the sensor holder on the chassis & fix it.
76
Procedure to assemble the edge avoiding robot using IR
Step 3: T
ake IR sensor, 3 male to female wires, allen key, nut and
bolt.
77
Procedure to assemble the edge avoiding robot using IR
Step 4: C
onnect male to female wires to the sensor.
78
Procedure to assemble the edge avoiding robot using IR
Step 5: A
ttach sensor on the chassis & fix it using allen key.
79
Procedure to assemble the edge avoiding robot using IR
Step 6: C
onnect sensor wires as per given below details.
80
Procedure to assemble the edge avoiding robot using IR
Step 7: A
dd cells in the cell holder.
81
Procedure to assemble the edge avoiding robot using IR
Step 8: T
urn ON the switch present on the cell holder.
82
Steps
Output:
You will see that the robot starts moving forward when there is no
edge. If the edge is detected then the robot will stop first > then turn
backward side > again stop > turn into right side.
Troubleshooting:
1. Issue: Robot is not working.
Solution: M
ake sure that you have connected battery with correct
polarity, otherwise reverse connection will cause battery
heating & robot will not work.
83
Activity 3.3 Human Following Robot
Components Required
Components Qty Components Qty
BO wheel 2 IR sensor 2
Caster wheel 1 AA batteries 6
84
Procedure to assemble the IR sensors and chassis and its connections
Step 1: T
ake two IR sensors and 4 male to female wires and connect
to the sensor.
85
Procedure to assemble the IR sensors and chassis and its connections
Step 2: M
ount those IR sensors on the chassis with the help of nuts
and bolts, allen key
86
Procedure to assemble the IR sensors and chassis and its connections
Step 3: C
onnect sensor wires as per below details.
87
Procedure to assemble the IR sensors and chassis and its connections
Step 4: P
ut batteries in the cell holder and turn on the switch on that
cell holder.
88
Steps
Code:
#define MLa 8 //left motor 1st pin
#define MLb 9 //left motor 2nd pin
#define MRa 10 //right motor 1st pin
#define MRb 11 //right motor 2nd pin
int IR_Left= 3;
int IR_Right= 4;
void setup()
{
pinMode(IR_Left, INPUT); // IR1 DO pin
pinMode(IR_Right, INPUT); // IR2 DO pin
pinMode(MLa, OUTPUT); // Motors pins
pinMode(MLb, OUTPUT);
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
89
Steps
}
void loop()
{
if (digitalRead(IR_Left) == HIGH && digitalRead(IR_Right) == HIGH)
{
// Stop
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
}
if (digitalRead(IR_Left) == LOW && dand digitalRead(IR_Right) == HIGH)
{
// will move in the left direction
digitalWrite(MLa, LOW);
90
Steps
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
}
if (digitalRead(IR_Left) == HIGH && digitalRead(IR_Right) == LOW)
{
// will move in the right direction
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
}
if (digitalRead(IR_Left) == LOW && digitalRead(IR_Right) == LOW)
{
// move in the forward direction
91
Steps
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
}
}
Output:
Y
ou can see the robot start moving when it detects an object in
front of the sensor. You can put an object in front of both sensors/
only at the left sensor or right sensor and check the robot working.
92
Activity 3.4 Line Follower Robot
Components Required
Components Qty Components Qty
93
Circuit Diagram:
94
Steps
Procedure:
1. I f You performed the previous Build a Motion Robot activity,
then keep the chassis model as it is because we are going to use
that model in this activity as it is. We are going to add only an IR
sensors on that model.
2. F irst remove batteries from the cell holder/ turn off the switch on
the cell holder.
3. C onnect an arduino board to your laptop/desktop using an arduino
cable.
4. Open Arduino IDE.
o to File > Examples > Sparklebox_code->Select build_a_Edge_
5. G
Avoiding_Robot_using_IR.
6. Go to Tools > Board > Select Arduino Uno.
95
Steps
Code:
#define MLa 8 //left motor 1st pin
#define MLb 9 //left motor 2nd pin
#define MRa 10 //right motor 1st pin
#define MRb 11 //right motor 2nd pin
#define L_sensor 3
#define R_sensor 4
void setup() {
pinMode(MLa, OUTPUT);
pinMode(MLb, OUTPUT);
pinMode(MRa, OUTPUT);
96
Steps
pinMode(MRb, OUTPUT);
pinMode(L_sensor, INPUT);
pinMode(R_sensor, INPUT);
Serial.begin(9600);
}
void loop() {
if((digitalRead(L_sensor) == LOW) && (digitalRead(R_sensor) == LOW)){
Serial.println(“Left and Right sensors are detecting”);
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
}
else if((digitalRead(L_sensor) == LOW) && (digitalRead(R_sensor) == HIGH)){
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
97
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
}
else if((digitalRead(L_sensor) == HIGH) && (digitalRead(R_sensor) == LOW)){
Serial.println(“Left not detecting”);
Serial.println(“Right detecting”);
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
}
else{
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
98
Steps
}
}
Procedure:
1. D efine motor pins and sensor pins which are going to connect with
the arduino board.
2. Define pinmode OUTPUT for motor pins and INPUT for sensor pins.
3. I f the black line is in between both the sensors, then turn Motors in
Forward direction only.
4. I f the black line is detected at the Left side, then turn the motor in
the right direction.
5. I f the black line is detected at the right side, then turn the motor in
the left direction.
6. If the black line is detected at both sides, then stop the motor.
99
Procedure to assemble the IR sensors on chassis and its connections
Step 1: T
ake two IR sensors, sensor holder, allen key , nuts and bolts
and constructed motion robot.
100
Procedure to assemble the IR sensors on chassis and its connections
Step 2: R
emove the caster wheel bottom bolts using allen key and
mount those sensor holders one side holes on the same bolts
using allen key.
• Attach the sensors to the sensor holders other holes with help of
nut and bolts,allen key.
101
Procedure to assemble the IR sensors on chassis and its connections
Step 3: T
ake 6 male to female wires.
102
Procedure to assemble the IR sensors on chassis and its connections
Step 4: C
onnect wires to the sensor pins as shown in image.
103
Procedure to assemble the IR sensors on chassis and its connections
Step 5: T
ake the wires of sensor from bottom to top of chassis
through holes and turn over the chassis to top and connect
sensor wires to the arduino board.
Step 6: P
ut batteries in the cell holder and turn ON the switch on that
cell holder.
104
Steps
Output:
1. D
raw black line or with the help of black electrical tape you can
make any shape on the paper as shown in the reference image
given below.
2. P
ut a robot on that line. make sure that black line should be in
between both the sensors.
105
Steps
Troubleshooting:
1. Issue: Robot is not working.
Solution: Please prefer the previous activity troubleshoot section.
2. Issue: I am facing issues with IR sensors.
Case 1: Both LEDs on the sensor are not working/glowing.
Solution: m
ake sure that wires are connected properly, avoid loose
connections.
Case 2: One LED is constantly ON but the other one is not glowing/
Sensor detects objects from very little distance.
Solution: P
ut any object in front of the sensor with a few distance.
Take a screwdriver and try to vary the blue pot on the
sensor.
106
107