DIY Human Following Robot (Final File)
DIY Human Following Robot (Final File)
Following
Robot
ACTIVITY 0: ........................................................................................ 11
• MAKE YOUR COMPUTER READY
• Download the arduino IDE.
• Download and add sparklebox code in arduino IDE
• Procedure to upload the code in arduino IDE
1
2
Know about Parts of Kit
3
Nut and Bolts
Tools
Structural Elements:
4
Hex Spacers
In electronics, Hex Spacers are frequently used to raise a
printed-circuit board above a surface.
Here it is used to mount caster wheels on the chassis.
Motion Elements:
Wheel
Castor Wheel
Castor is an undriven wheel that is designed to be attached to the bot-
tom of a larger object (the “vehicle”) to enable that object to be moved
5
DC Motor
Male-to-Female:
Single / Group of Electric wires with connector or pin at each end. It is
used to interconnect the components. Female ends are used to plug things
into.
Male-to-Male:
The difference between these wires is in the endpoint of the wire. Male
ends have a pin protruding and can plug into things.
AA Battery
AA batteries are multi-purpose alkaline batteries ideal for reliably powering
everyday devices. You can use it in regularly used devices such as portable
games consoles, watches, shavers, motorized toys, flashlights, and
toothbrushes.
6
AA battery holder
Screws Driver
Allen Key
Control Elements:
IR Sensor
7
Arduino UNO
The Arduino UNO is a microcontroller board based on a removable, dual-inline-package (DIP) ATmega328
AVR microcontroller.It is a board based microcontroller (small computer on a chip) with facilities for
processing data and I/O (input and output) pins for receiving and sending signals to devices. It can be
powered and programmed using a computer or mobile phone.
Features:
• Microcontroller: ATmega328
• Operating voltage: 5 V
• Input voltage (recommended): 7-12 V
• Digital I/O pins: 14 (of which 6 provide PWM output)
• Analog input pins: 6
• DC current per I/O pin: 40 mA
• DC current for 3.3V pin: 50 mA
• Flash memory: 32 KB (ATmega328) of which 0.5 KB is used by the bootloader
• SRAM: 2 KB (ATmega328)
• EEPROM: 1 KB (ATmega328)
• Clock speed: 16 MHz
8
Arduino Uno Cable
Arduino contains a mini/micro or type B USB port that can be used to
connect to a PC via the regular USB port, and the connection is done via
a USB cable.
Note:
Consumables are goods used by individuals and businesses that must be replaced regularly because they wear
out or are used up.
Here the consumables are listed as:
• Spacers, screws, nut and bolts
• 4 X AA battery cells and holder
• Jumper connectors
Precautions
• Always keep your work area clean, neat and dry.
• Never work on circuit connections while power is applied.
• Do not connect power to a circuit until the circuit is finished.
9
• Double-check the polarities of any power connections while you make.
• If you smell anything burning, immediately disconnect the power and examine your circuit to find out
what went wrong.
• Always ensure that all electronics equipment is properly grounded.
• Don’t work with metallic jewelry on your hands like watches, rings, and bracelets.
• Keep a consistent wiring color code for jumper/connecting wires. Use red wire for power and black
wire for ground.
• Be careful what you touch while troubleshooting.
Prerequisite
Prerequisite
The only things required are
• DIY Human Following Robot Kit
• Laptop / Computer System
10
Let’s Get Started With Your Activities
• Software - Used to compose your programs, and communicate with the hardware, called an integrated
development environment (Arduino IDE)
• Hardware - Refers to the boards themselves (e.g. Arduino Uno)
• Programming language - The Arduino programming language is based on C.
The Arduino IDE allows you to write programs and upload them to your Arduino.
The Arduino IDE (software for composing code and sending it to your board) runs on Windows, Mac OS X,
and Linux.
Depending on your operating system, your software installation procedure will vary. With an internet
enabled computer, open up your browser and type in the following URL into the address bar
https://www.arduino.cc/en/software.
When you open this link, You will find these options on your chrome window.
1. For Windows OS with any version select “Windows win 7 and a newer” option,
it will download the Arduino IDE software.
2. For Linux, select the “Linux 32 bits/Linux 64 bits” option as per your computer.
3. For Mac OS select the “Mac OS X 10.10 or newer” option.
11
Then you will be redirected to the Support page of Arduino IDE. Then click on the Click“Just DOWNLOAD”
option
Then arduino software will start downloading. Once the download is completed, go to the arduino software
downloaded location on your computer. Then double click on the Arduino.exe file.
12
Then a new window will open “Do you want to allow this app to make changes to your device” click on Yes
After that, the Arduino Setup License Agreement window will open. Click on “I Agree”.
Then the Arduino Setup Installation options window will open. Check all the boxes and click on next.
13
Then Arduino Setup Installation Folder windows will open then click on the “Install” option. Then the
installation will start.
Note:
While installing if you get any new window like “install USB Port Driver” click the install option.
14
Once it’s installed, on your desktop you will find the arduino icon, double
click on it.
Each of the circuits you will build in the Sparkle Box Kit has an arduino code
sketch already written for it. This guide will show you how to manipulate that
code to control your hardware.
2. Select DIY Human Following Robot and click on the code or program zip file link.
Your browser will download the code automatically or ask you if you would like to download the .zip file.
Select “Save File.” Locate the code (usually in your browser’s “Downloads” folder). You’ll need to relocate
it to the “Examples” subfolder in your Arduino IDE installation in order for it to function properly. Unzip the
file “SPARKLEBOX CODE.” It should be located in your browser’s “Downloads” folder. Right-click (or ctrl +
click) the zipped folder and choose the “unzip/Extract Here option.
WINDOWS: Copy or move the unzipped “SPARKLEBOX Code” files from “Downloads” to the arduino
application’s “Examples” folder
(x86)
MAC OS: Find “Arduino” in your “Applications” folder in Finder. Right-click (ctrl + click) on “Arduino” and
select “Show Package Contents.”
15
Copy or move the unzipped “SPARKLEBOX Code” folder from your “Downloads” folder into the Arduino
application’s folder named “Examples.”
New
Note:
These steps are the same for all activities.
16
1. Connect arduino board to your laptop/desktop using arduino cable.
2. Open program file in arduino IDE.
3. Go to Tools-> Board->Select Arduino Uno.
17
Components Testing Activities
Note:
Testing arduino board
Components required
1. Arduino UNO - 1
2. Arduino Uno Cable - 1
Procedure
1. Connect arduino to your laptop/desktop using arduino cable.
2. Open arduino IDE.
3. Open LED blink example in arduino IDE.
4. Go to File->Examples->Sparklebox code->Select Led_Blinking.
5. Go to Tools->Board->Select Arduino Uno.
6. Go to Tools->Port->Select COM port.
7. Click on the verify option.
8. Click on the upload option.
Code:
Note:
You will find this program in your arduino IDE examples after adding the “SPARKLEBOX CODE” folder to your
arduino IDE.
// the setup function runs once when you press reset or power the board
void setup() { // initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
18
// the loop function runs over and over again forever
void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Program Overview
1. Turn the LED on by sending high signal(5v) to digital pin 13.
2. Wait 1 seconds(1000 milliseconds).
3. Turn the LED off by sending low signal(0v) to digital pin 13.
4. Wait 1 seconds(1000 milliseconds).
5. Repeat.
Code To Note
1. SETUP AND LOOP:
void setup() {} and void loop() {}
Every arduino program needs these two functions. Code that goes in between the curly brackets {}
of setup()runs once. The code in between the loop()curly brackets {} runs over and over until the
Arduino Board is reset or powered off.
2. INPUT OR OUTPUT
pinMode(LED_BUILTIN, OUTPUT);
Before you can use one of the digital pins, you need to tell the arduino whether it is an INPUT or
OUTPUT. We use a built-in “function” called pinMode() to make pin 13 a digital output.
3. DIGITAL OUTPUT:
digitalWrite(LED_BUILTIN, HIGH);
When you’re using a pin as an OUTPUT, you can command it to be HIGH (output 5 volts) or LOW
(output 0 volts).
19
4. DELAY:
delay(1000);
Causes the program to wait on this line of code for the amount of time in between the brackets,
represented in milliseconds 1000ms = 1s). After the time has passed, the program will continue to the
next line of code
5. COMMENTS:
// wait for a second
/*so is this*/
Comments are a great way to leave notes in your code explaining why you wrote it the way you did.
Single line comments use two forward slashes //, while multi-line comments start with a /* and end
with a */.
Output
1. After uploading the code you will find arduino inbuilt “L” labled LED blinking.
20
Troubleshooting
1. Issue: Error occurs while uploading the code.
Solution: Disconnect the cable and connect once again, make sure that you selected the board as arduino
Uno and valid COM port, now try to upload the code.
Challenge Task:
1. Blink the Led after every 2 seconds.
2. Try to change the delay between led on/off and generate a particular led blink pattern.
21
Activity 2: Interfacing IR sensor with Arduino
Note:
Testing IR sensor.
Signal LED
Components required
1. IR sensor - 1 3. Arduino Uno Cable - 1
2. Arduino UNO - 1 4. Jumper Wires M/F - 3
Procedure
1. Connect arduino to your laptop/desktop using arduino cable.
2. Open arduino IDE.
3. Go to File->Examples->Sparlebox_code->Select interfacing_IR_sensor_with_Arduino.
4. Connect the arduino board to your computer/laptop using an arduino cable.
5. Go to Tools->Board->Select Arduino Uno.
6. Go to Tools->Port->Select COM port.
7. Click on the upload option.
8. Now do the wiring connections as shown below.
22
PIN 2
Arduino Sensor
5v VCC
Pin no 2 OUT
GND GND
GND
5V
Code:
Note:
You will find this program in interfacing_IR_sensor_with_Arduino example.
#define IR 2
void setup()
{ // put your setup code here, to run once:
Serial.begin(9600);
pinMode(IR,INPUT);
}
void loop()
{ // put your main code here, to run repeatedly:
int IR_read = digitalRead(IR);
if(IR_read==0)
Serial.println(“object detected”);
else
Serial.println(“No object”);
}
23
Program Overview
1. Define arduino pin number to which sensor OUT pin is going to connect.
2. Enable serial communication with 9600 baud rate.
3. Define pinmode for sensor as INPUT pin.
4. Read the data which is coming at the OUT pin of the sensor.
5. If received data is 0 then print object detected text on serial monitor.
6. If received data is 1 then print No object text on serial monitor.
7. Repeat.
Code To Note
1. DIRECTIVE
#define IR 2
#define is a useful C++ component that allows the programmer to give a name to a constant value
before the program is compiled. Defined constants in arduino don’t take up any program memory space
on the chip. The compiler will replace references to these constants with the defined value at compile
time.
2. USER-DEFINED FUNCTION:
Serial.begin(9600);
Sets the data rate in bits per second (baud) for serial data transmission. For communicating with
Serial Monitor, make sure to use one of the baud rates listed in the menu at the bottom right corner of
its screen.
Serial.println(“object detected”);
Prints data to the serial port as human-readable ASCII text. The println(“...”) method prints the
string and moves the cursor to a new line.
3. IF STATEMENT:
if(IR_read==0)
Serial.println(“object detected”);
The if-else statement in C is used to perform the operations based on some specific condition.
The operations specified in the if block are executed if and only if the given condition is true.
Otherwise the operation specified in the else block will execute.
24
Output
1. After uploading the code and proper wiring connection, just open the
serial monitor. See in the given image, how to open a serial monitor in the
arduino IDE.
open serial
monitor by
press this icon
You will find this text on your serial monitor as shown in the above image.(Note: select baud rate as 9600 baud)
No object: when there is no object in front of the sensor
Object detected: when there is an object present in front of the sensor.
Troubleshooting
• Issue: Both the Led’s on the sensor are not Working/Glowing.
• Solution: Make sure that wires are connected properly,avoid loose connections.
• Issue: One Led(power LED) is ON but the 2nd Led is not glowing/ Sensor detects objects from very
little distance.
• Solution: Put any object in front of the sensor with a few distance. Take a Screwdriver and try to vary
the blue pot on the sensor.
Note:
Second LED will blink only when it detects object in front of sensor.
Challenge Task:
1. Turn on the buzzer only if there is an object in front of the sensor.
25
Activity 3: Build a Motion Robot
Note:
Testing motors and motor driver module
Components required
5. Battery (AA Cell , 1.5V) - 4
1. Arduino UNO - 1 6. Battery Cell Holder - 1
2. Arduino Uno Cable - 1 7. Jumper wires(M/M) - 2
3. Motor Driver Module - 1 8. Jumper wires(M/F) - 4
4. DC Motors - 2 9. MDF chassis Board - 1
Procedure
1. Connect arduino to your laptop/desktop using arduino cable.
2. Open arduino IDE.
3. Go to File->Examples->Sparkle box_code->Select build_a_Motion_Robot.
4. Go to Tools->Board->select Arduino UNO.
26
5. Go to Tools->Port->select com port(Arduino).
6. Click on the verify option.
7. Click on the upload option.
Program Overview
1. Define motor pins which are going to connect with the arduino board.
2. Define PinMode for those pins as output pins.
3. Stop the motor for 1 second.
4. Turn the motor in the forward direction for 2 seconds.
5. Turn the motor in the backward direction for 2 seconds.
6. Turn the motor in the left direction for 2 seconds.
7. Turn the motor in the right direction for 2 seconds.
8. Repeat.
Code To Note
Note:
DIRECTIVE, INPUT OR OUTPUT, DIGITAL OUTPUT, DELAY functions are explained in 1st activity kindly refer
further activities.
Code:
27
void loop() {
//stop both the motors//
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
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
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//
}
Note:
Scan the QR Code/URL for support present on the back side of the manual select the human following robot and
then select Build a Motion Robot to get the video reference file for assemble of the robot.
28
Procedure to Assemble motors and boards on chassis
1. Take a MDF sheet of robotic chassis.
29
3. Take two motor clamps and lock clamps along with the chassis as shown in image.
• Insert the motor clamps to motor slots on • Turn over the chassis to top and insert the lock
chassis from bottom to top as shown in image. clamps to motor clamps as shown in image.
30
4. Take clamps, motors, M3x30 nuts and bolts.
5. Take 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.
Note:
Please make sure motor wires should come inside of the chassis while attaching motor support clamps.
31
6. Similarly, attach the 2nd motor to the bottom side of the chassis as shown in the image.
7. Now 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.
32
8. Now take two wheels and fix it with motor shaft by aligning properly and by press fit.
9. Take 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.
33
10.Take 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.
11.From 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.
34
12.Take the cell holder, double sided tape and Attach it on the bottom side of the chassis using double
sided tape as shown in image.
13.Connect cell holder wires to the motor driver module as per given details.
Cell holder Motor driver Module
Red wire (+ve) polarity
Black wire (-ve) polarity
35
14.Take another one red and black(you can take any coloured wire) male to male wire and connect it to
the motor driver module.
Motor driver Module
Red wire (+ve) polarity
Black wire (-ve) polarity
15.Connect motor driver module red and black wires to the arduino board as per given details.
Arduino Board
Red wire VIN
Black wire GND
36
16.Take 4 male to female wires and connect it to the motor driver module input pins.
1st pin
1st pin
2st pin 2st pin
37
17.Take 4 cell batteries and put them inside the cell holder.
• You will find one switch on the cell holder, switch it to off.
38
18.Take a wing with a holder and attach it on the chassis as shown in below image.
Output
You can see the robot is moving forward, backward and in left, right direction.
Troubleshooting
Issue: Motors are not working.
Solution:
1. Check whether you connected all batteries with the correct polarity or not in the cell holder.
2. If all these above robot assembly steps are completed then check whether the switch on the cell
holder is turned on or not.
3. If the motors are not working as coded, try interchanging 8,9 and 10,11 pins on arduino board.
4. Do not attach the battery all the time to the ckt, otherwise it will drain the batteries, due to that
the robot will not work. Remove all the batteries from the cell holder once you finish the work.
5. If the switch is ON and connections are correct, then check whether the Led on the arduino
board is on, if not then batteries are drained and need to replace it.
• Issue: Motor clamps are not fitting properly with the chassis.
• Solution: With the help of a screwdriver, widen the chassis clamp slot.
Challenge Task:
1. Try to move the robot in a square and circular path by changing the code/program.
39
Build Your Robot
Circuit Diagram
Components required
1. MDF Chassis - 1 6. Motor Driver -1
2. BO Motors - 2 7. IR sensor - 2
3. BO Wheel - 2 8. AA Batteries - 4
4. Castor Wheel - 1 9. Jumper Connectors - 12
5. Arduino UNO - 1 10.Arduino UNO cable - 1
40
Procedure
1. If 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. First remove batteries from the cell holder.
3. Connect an arduino board to your laptop using an arduino cable.
4. Open arduino IDE.
5. Go to File->Examples->Sparklebox_code->Select build_a_Human_Following_Robot.
6. Go to Tools->Board->Select Arduino Uno.
7. Go to Tools->Port->Select com port(Arduino).
8. Click on the verify option.
9. Click on the upload option.
10.Disconnect arduino cable from the arduino board.
Code:
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);
41
pinMode(MRb, OUTPUT);
}
void loop()
{
42
{
// move in the forward direction
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
}
}
Program Overview
1. Define 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. If there is no object detected in front of the sensor, turn motors in Forward direction only.
4. If an object is detected at the Left side, then turn the motor in the Left direction.
5. If an object is detected at the Right side, then turn the motor in the Right direction.
6. If an object is detected in front of the sensor, then stop the motors.
Code To Note
Note:
DIRECTIVE, INPUT OR OUTPUT, DIGITAL OUTPUT, functions , IF statement are explained in 1st and 2nd
activity kindly refer to further activities.
Note:
Scan the QR Code/URL for support present on the back side of the manual select the human following robot to
get the video reference file for assemble of the robot.
43
Procedure to assemble the IR sensors on chassis and its connections
1. Take two IR sensors and 4 male to female wires and connect to the sensor.
2. Mount those IR sensors on the chassis with the help of nuts and bolts, allen key.
44
3. Connect sensor wires as per below details.
Sensor Arduino
Left sensor VCC 5V
GND GND
OUT Pin no 3
Right sensor VCC IOREF
GND GND
OUT Pin no 4
4. Put batteries in the cell holder and turn on the switch on that cell holder.
45
Output
You 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.
Troubleshooting
Issue: Robot is not working.
Solution:
1. Check whether you connected all batteries with the correct polarity or not in the cell holder.
2. If all these above robot assembly steps are completed then check whether the switch on the cell
holder is turned on or not.
3. If the motors are not working as coded, try interchanging 8,9 and 10,11 pins on arduino board.
4. If the switch is ON and connections are correct, then check whether the Led on the arduino
board is on, if not then batteries are drained and need to replace it.
Note:
1. Switch Off the robot switch present at battery holder once robot not in use.
2. Do not connect batteries all-time with the circuit, because the circuit will drain all the batteries. So just
remove all the cell batteries when your robot not in use.
46
Note
47
Note
48
Note
49
EdRoboVate is a robotics kit with various Robotics & STEM-related projects and activities for the children to
ignite their young minds. This kit helps children to improve their critical and logical thinking ability and also
Robotics is beneficial to cognitive development as it improves the health of the brain and prevents neural
deterioration, with the help this a child can learn Robotics easily and thus helps them to pave their future.
Published by
www.mysparklebox.com info@mysparklebox.com