Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DIY Obstacle Avoiding Robot

You might also like

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

DIY OBSTACLE

AVOIDING
ROBOT

Code, Build, Play & learn.....


Index
INTRODUCTION ................................................................................... 01
• Know Your Kit of Parts
• Structural Elements
• Motion Elements
• Power, Tools, and Accessories Elements
• Control Elements
• Precautions

MAKE YOUR COMPUTER READY ........................................................... 08


• Download the Arduino IDE.
• Download and Add sparklebox code in Arduino IDE
• Procedure to upload the code in Arduino IDE

ACTIVITY 1: ....................................................................................... 15
• LED Blinking

ACTIVITY 2: ....................................................................................... 18
• Interfacing Ultrasonic Sensor with Arduino

ACTIVITY 3: ...................................................................................... 23
• Build a Motion Robot

ACTIVITY 4: ...................................................................................... 33
• Build an Obstacle Avoider Robot
Know about your kit parts

MDF Chassis Board DC Motor Arduino UNO Motor Driver

Castor Wheel Wheels AA Battery AA Cell Holder

Ultrasonic Sensor Male-to-Female Male-to-Male Arduino Cable

1
Nut and Bolts

Nuts(M3) Bolts(M3X6) Bolts(M3X12) Bolts(M3X30) Hex Spacers

Tools

Allen Key Screws Driver

Structural Elements:

MDF Chassis Board


A chassis is a framework that structurally supports the base of the robot car, to which other electronic
components are mounted.

2
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.

Nut and Bolts


A nut is a type of fastener, a hollow circular cylinder that is always used with the bolt. The bolt is a solid
cylindrical fastener used with the nut.

Motion Elements:

Wheel

A drive wheel is a motor vehicle wheel that transmits force, causing


the vehicle to move.

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

3
DC Motor

A DC motor is any of a class of rotary electrical motors that converts


direct current electrical energy into mechanical energy when electricity
is applied to its leads. If the direction of the electricity is reversed, the
motor will spin in the opposite direction.

Connectors, Power, Tools & Accessories Elements :

Jumper/ Connecting cables

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.

4
AA battery holder

It is a simple case with terminals, for holding the batteries.

Screws Driver

A screwdriver is a handy choice when trying to fix small appliances or


hardware, for turning screws with slotted heads.

Allen Key

An L-shaped metal bar with a hexagonal head at each end is used to


turn bolts and screws having hexagonal sockets.

Control Elements:

Ultrasonic Sensor

An ultrasonic sensor is an electronic device that is used to mea-


sure the distance of an object by emitting ultrasonic sound waves.
It converts the reflected sound waves into an electrical signal.
This is exactly how bats navigate in the dark. A bat can produce
ultrasonic sound waves that bounce off a wall, or an insect so the
bat knows where there is an obstruction and where there is food.

Ultrasonic sensors have two main components:


1. The transmitter - emits the ultrasonic sound using
piezoelectric crystals.
2. The receiver - receives the ultrasonic sound after it has
travelled to and from the target.

5
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

6
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.

L293D Motor Driver

The Motor Driver is a module for motors that allows you to


control the working speed and direction of two motors
simultaneously. This Motor Driver is designed and
developed based on L293D IC. L293D is a 16 Pin Motor
Driver IC.

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 & Bolts
• 4 X AA battery cells & 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.

7
• 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 Obstacle avoiding robot kit
• Laptop / Computer System

Make Your Computer Ready

• 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.

• Download the Arduino IDE (Integrated Development Environment)

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.

8
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.

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.

9
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.

10
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.

After completing installation click on “close” option.

11
Once it’s installed, On your desktop you will find the Arduino icon, double
click on it.

DOWNLOAD AND ADD THE SPARKLEBOX CODE FOLDER IN ARDUINO IDE.

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.

DOWNLOAD THE CODE:


1. Please type the below URL into your browser tab and click enter.
https://mysparklebox.com/robotic-faq

2. Select DIY Obstacle Avoider Robot and click on the code or program zip file link.

COPY “SPARKLEBOX CODE” INTO “EXAMPLES” LIBRARY IN ARDUINO FOLDER

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

MAC OS: Find “Arduino” in your “Applications” folder in Finder. Right-click (ctrl + click) on “Arduino” and
select “Show Package Contents.”

12
Copy or move the unzipped “SPARKLEBOX Code” folder from your “Downloads” folder into the Arduino
application’s folder named “Examples.”

OPEN THE ARDUINO IDE:

• Open the Arduino IDE software on your computer

• Procedure to upload the code to the Arduino Board.

Note:
These steps are the same for all activities.

13
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

4. Go to Tools->Port->Select COM port(Arduino Uno).

5. Click on the Verify option.


6. Click on the Upload option.

14
Let’s Get Started With Your First Activity!

Activity 1: LED Blinking

Components required
1. Arduino UNO - 1
2. Arduino Uno Cable - 1

Procedure
1. Open Arduino IDE.
2. Open LED Blink example in Arduino IDE.
3. Go to File->Examples->Sparklebox code->Select Led_Blinking.
4. Go to Tools->Board->Select Arduino Uno.
5. Go to Tools->Port->Select COM port.
6. Click on the Compile option.
7. 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);
}

15
// 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() {} & 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).

16
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.

17
Troubleshooting
1. Issue: error occurs while uploading the code.
Solution: Disconnect the cable & connect once again, Make sure that you selected the Board as Arduino
Uno & 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 & generate a particular led blink pattern.

Activity 2: Interfacing ultrasonic sensor with Arduino

Components required
1. Ultrasonic sensor - 1
2. Arduino UNO - 1
3. Arduino Uno Cable - 1
4. Jumper Wires -4

18
Procedure

1. Open Arduino IDE.


2. Install New Ping Library. Go to Sketch->Include Library->Manage Libraries.

3. The Library window will open, type NewPing & hit enter.
4. You will find NewPing Library, select that Library & click on the Install option.

Note:
You must have an internet connection to install the library.

19
5. After installation, close the library window.
6. Go to File->Examples->Sparklebox_code->Select interfacing_Ultrasonic_sensor_with_Arduino
7. Connect the Arduino Board to your computer/laptop using an Arduino cable.
8. Go to Tools->Board->Select Arduino Uno.
9. Go to Tools->Port->Select COM port.
10. Now Do the wiring connections as shown below.

Code:

Note:
You will find this program in Interfacing Ultrasonic sensor with Arduino

#include <NewPing.h>

#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 7 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor
distance is rated at 400-500cm.

20
void setup()
{
Serial.begin(9600); // Open serial monitor at 9600 baud to see ping results.
}

void loop()
{
delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between
pings.
Serial.print(“Ping: “);
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance
range)
Serial.println(“cm”);
}

Program Overview
1. Define Arduino pin no which is connecting to sensor Trig & Echo pin.
2. Turn on Serial Communication.
3. Check what distance the sensor is reading.
4. Print that distance on Serial Monitor.

Code To Note
1. DIRECTIVE
#define TRIGGER_PIN 6
#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. CONSTRUCTOR
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
This initializes NewPing to use a pin for trigger output, pin for echo input, with a maximum ping
distance of 200cm. max_cm_distance is optional [default = 500cm].

21
3. 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.print(“Ping: “);
Prints data to the serial port as human-readable ASCII text.

sonar.ping_cm();
Send a ping, returns the distance in centimeters or 0 (zero) if no ping echo within the set distance limit.

Output
1. To see the Distance values on the serial monitor, just click on this icon.

2. Distance values will print on the Serial monitor. open serial


monitor by
press this icon

Note:
Select the “baud 9600” if it is not selected by default in “serial monitor window”.

22
Troubleshooting
1. Issue: distance is showing 0 cm all time.
2. Solution: fix your wiring connection & avoid loose connections.

Challenge Task:
1. Try to use this distance, for less than 20cm distance write “distance less than 20cm” on Serial monitor
& for greater than 20 cm write “distance greater than 20 cm”.

Activity 3: Build a Motion Robot

Components required
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
5. Battery (AA Cell , 1.5V) - 4

23
Procedure
1. Open Arduino IDE.
2. Go to File->Examples->Sparkle box_code->Select build_a_Motion_Robot
3. Go to Tools->Board->select Arduino UNO.
4. Go to Tools->Port->select com port(Arduino).
5. Click on the verify option.
6. 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:

#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()
{

24
pinMode(MLa, OUTPUT);
pinMode(MLb, OUTPUT);
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
}
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 both Motors in left Direction//
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, HIGH);
delay(2000); //wait for 2 second//
//Rotate both Motors in right Direction//
digitalWrite(MLa, LOW);

25
digitalWrite(MLb, HIGH);
digitalWrite(MRa, HIGH);
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 obstacle avoider robot to
get the video reference file for assemble of the robot.

Procedure to Assemble motors & boards on chassis


1. Take a MDF sheet of robotic chassis.

2. Separate all the parts from the chassis sheet.

26
3. Take clamps, motors, M3x30 nuts & bolts.

4. Take two motor clamps and lock clamps along with chassis as shown in image.

• Insert the motor clamps to • Turn over the chassis to top and
motor slots on chassis from insert the lock clamps to motor
bottom to top as shown in clamps as shown in figure.
image.

27
5. Take two motors and attach one motor 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 attching motor support
clamps.)

6. Similarly, attach the 2nd motor to the bottom side of the chassis as shown in the image.

7. Now take caster wheels, nuts & bolts, hex spacers & Attach caster wheel on the bottom side of the
chassis using bolts and Allen key as shown in image.

28
8. Now take two wheels & fix it with motor shaft by aligning properly and by press fit.

9. Take an Arduino Board, nuts & bolts & Attach it on the top of the chassis with the help of nuts & bolts
and Allen key as shown in image.

10. Take the Motor driver module, nuts & bolts & Attach it on the top of the chassis using nuts & bolts and
Allen key as shown in image.

29
11. Take the battery holder, double sided tape & Attach it on the bottom side of the chassis using double
sided tape as show in image.

12. From the down side of the chassis put motor wires on the top side through holes & connect it to the
motor driver module using screwdriver as shown in below image.

13. Connect cell holder wires to the motor driver module as per given details.
Motor driver
Cell holder
Module
Red wire -------- (+ve) polarity
Black wire ------- (-ve) polarity

30
14. Take another one red & black male to male wire & connect it to the motor driver module.
Motor driver module
Red wire---------- (+ve) polarity
Black wire---------(-ve) polarity

15. Connect Motor driver module red & black wires to the Arduino Board as per given details.

Arduino Board
Red wire-------VIN
Black wire-----GND

16. Take 4 male to female wires & connect it to the motor driver module input pins.

31
Motor driver Arduino(pins) module
MC5(1st pin) --------- 8
MC5(2nd pin) --------- 9
MC6(1st pin) --------- 10
MC6(2nd pin) --------- 11

17. Take 4 Cells & put them inside the battery holder.

18. Take a wing with a holder & attach it on the chassis as shown in below image.

32
Output
You can see the robot is moving forward, backward and in left, right direction.

Troubleshooting
Issue: Motors are not working.
Solution:
1. If the motors are not working as coded, try interchanging 8,9 & 10,11 pins on Arduino Board.
2. Do not attach the battery all the time to the circuit, otherwise it will drain the batteries, due to
that the robot will not work. Remove all the batteries from the holder once you finish the work.
Issue: Motor clamps are not fitting properly with the chassis.
Solution:
3. With the help of a screwdriver or allen key, please widen the chassis clamp slot.
Challenge Task:
1. Try to move the robot in a square & circular path by changing the code/program.

Activity 4: Build Obstacle Avoider Robot

33
Components required

1. MDF Chassis - 1 6. Motor Driver -1


2. BO Motors - 2 7. Ultrasonic sensor - 1
3. BO Wheel - 2 8. AA Batteries - 4
4. Castor Wheel - 1 9. Jumper Connectors - 10
5. Arduino UNO - 1 10. Arduino UNO cable - 1

Procedure

1. If You performed the previous Interfacing motors with Arduino using motor driver. 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 ultrasonic sensor on that model.
2. First remove batteries from the battery 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_Obstacle_Avoider_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.

Program Overview

1. Define Motor pins & sensor pins which are going to connect with the Arduino Board.
2. Define PinMode for those pins as OUTPUT, except Echopin as INPUT pin.
3. Check what distance the sensor is reading.
4. If the distance is greater than 15cm, then turn motors in Forward direction only.
5. If the distance is less than 10 cm, then stop the Motors, move backward side, stop again & then turn
into left direction.
6. Repeat.

34
Code To Note
1. DATATYPE
long duration, distance;
The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits.
2. IF STATEMENT:
if (logic statement) {
// run the statement if it’s true
}
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.

Code:

#define trigPin = 6; // Trig Pin Of HC-SR04


#define echoPin = 7; // Echo Pin Of HC-SR04
#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
long duration, distance;

void setup()
{
Serial.begin(9600);
pinMode(MLa, OUTPUT); // Set Motor Pins As O/P
pinMode(MLb, OUTPUT);
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
pinMode(trigPin, OUTPUT); // Set Trig Pin As O/P To Transmit Waves
pinMode(echoPin, INPUT); //Set Echo Pin As I/P To Receive Reflected Waves
}
void loop()

35
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // Transmit Waves For 10us
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH); // Receive Reflected Waves
distance = duration / 58.2; // Get Distance
Serial.println(distance);
delay(10);
if (distance > 15) // Condition For Absence Of Obstacle
{
digitalWrite(MRb, HIGH); // Move Forward
digitalWrite(MRa, LOW);
digitalWrite(MLb, HIGH);
digitalWrite(MLa, LOW);
}
if (distance < 10) // Condition For Presence Of Obstacle
{
digitalWrite(MRb, LOW); //Stop
digitalWrite(MRa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MLa, LOW);
delay(500);
digitalWrite(MRb, LOW); // Move Backward
digitalWrite(MRa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MLa, HIGH);
delay(500);
digitalWrite(MRb, LOW); //Stop
digitalWrite(MRa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MLa, LOW);
delay(100);

36
digitalWrite(MRb, HIGH); // Move Left
digitalWrite(MRa, LOW);
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
delay(500);
}
}

Note:
Scan the QR Code/URL for support present on the back side of the manual select the obstacle avoider robot to
get the video reference file for assemble of the robot.

Procedure to assemble sensor on chassis & its connections


1. Take the Ultrasonic sensor holder & its required parts. Attach that holder on the chassis as shown in
below image.

2. Take an Ultrasonic sensor & connect 4 male to female wires to that sensor. Attach the sensor on the
chassis.

37
3. Do the Sensor connections with the Arduino Board as per given details.

Sensor Arduino
VCC ---------- 5V
Trig ---------- pin no 6
Echo ---------- pin no 7
GND ---------- GND

4. Put the Cells in the Cell holder & now your obstacle avoider Robot is ready.

Output
When the boards & sensor connections are properly done with batteries attached, the robot will work
immediately. Try to check the robot by putting an object in front of the sensor’s eyes.

Program Overview
1. Define sensor pins
2. If any obstacle is in front of the robot.
3. Stop the robot.
4. Take robot slightly reverse
5. Then stop the robot
6. Turn the robot in left direction
7. If there is no object then move the robot forward

38
Troubleshooting
Issue: Robot is not working.
Solution:
1. Check whether you connected all batteries in the battery holder or not.
2. If batteries are connected then check whether the Arduino board is getting power or not
through the VIN & GND pin on Still no power, then you need to replace the batteries with new.
3. If ok then check with motor wire & sensor connections with Arduino Board.

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.

39
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

K12 Techno Services Pvt. Ltd.


Bengaluru, Karnataka, India, 560022.

www.mysparklebox.com info@mysparklebox.com

Scan the QR Code for Sparklebox digital support

EXPERIENCING A PROBLEM NOT COVERED BY THE MANUAL?


We are constantly working to improve your Obastacle Avoiding Robot Kit experience.
Visit our Sparklebox support page at https://mysparklebox.com/robotic-faq to find a solution

You might also like