Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

DIY Voice

Controlled
Robot

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


Index
INTRODUCTION ................................................................................... 01
• Glimpse of voice controlled robot
• Know your kit of parts
• Structural elements
• Motion elements
• Power, tools, and accessories elements
• Control elements
• Precautions

MAKE YOUR COMPUTER READY ........................................................... 10


• Download the arduino IDE
• Download and add sparklebox code in arduino IDE
• Procedure to upload the code in arduino IDE

ACTIVITY 1: ....................................................................................... 17
• Print Hello World

ACTIVITY 2: ....................................................................................... 20
• LED Blinking

ACTIVITY 3: ....................................................................................... 23
• Interfacing Bluetooth with Arduino

ACTIVITY 4: ........................................................................................ 30
• Build a Motion Robot

ACTIVITY 5: ........................................................................................ 44
• Build a Voice Controlled Robot
Glimpse of Voice Controlled Robot

1
2
Know about your kit parts

MDF Chassis Board DC Motor Arduino UNO Motor Driver

Castor Wheel Wheels AA Battery AA Cell Holder

Bluetooth Module Male-to-Female Male-to-Male Arduino Cable


Jumper Cable Jumper Cable

3
Nut and Bolts

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

Tools

Allen Key Screw Drive


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.

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.

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
bottom of a larger object (the “vehicle”) to enable that object to be
moved.

5
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 and 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.

6
AA battery holder

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

Screw 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:

Bluetooth Module

This module has two-way (full-duplex) wireless


functionality. It is used to communicate between two
microcontrollers like Arduino or communicate with any
device with Bluetooth functionality like a Phone or
Laptop. There are many android applications that are
already available which makes this process a lot easier.
The module communicates with the help of USART at 9600
baud rate hence it is easy to interface with any
microcontroller that supports USART.
Applications:
Wireless Robots, Home Automation.

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.

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 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 Voice Controlled 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.

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

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

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

13
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 Voice Controlled 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.”

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

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

16
Let’s Get Started With Your First Activity!

Activity 1: Print Hello World

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 Hello World Example in arduino IDE. Go to File->Examples->Sparklebox_code->Select
hello_world.
4. Go to Tools->Board->Select arduino Uno.
5. Go to Tools->Port->Select Com Port(Arduino).
6. Click on the compile/verify option.
7. Click on the upload option.

Code:

Note:

You will find this program in your arduino IDE hello_world example after adding the “SPARKLEBOX CODE”
folder to your arduino IDE.

void setup()
{
Serial.begin(9600);
}

void loop()

17
{
Serial.begin(“Hello World”);
}

Program Overview

1. Enable serial communication with 9600 Baud Rate.


2. Write in loop what text you want to print on serial monitor, it will print that text continuously.

Output

1. To see the text on serial monitor, just click on this icon in your arduino IDE.
2. You can see your text Hello World! there.
3. (Note: select baud rate 9600 baud)

open serial
monitor by
press this icon

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.

18
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(“Hello World”);
Prints data to the serial port as human-readable ASCII text.

Troubleshooting

1. Issue: Error occurs while uploading the code.


Solution:
1. Do not write anything in the code, otherwise it will give compilation errors.
2. 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.
2. Issue: No text, only “?” prints on Serial monitor.
Solution:
On serial monitor you will find one option related to baud rate, select 9600 baud option from the list.

Challenge Task:

1. Print your name on serial monitor.


2. Print 5 lines about arduino on serial monitor only once.
(Hint: write your text in setup only)

19
Activity 2: LED Blinking

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);
}
// the loop function runs over and over again forever
void loop()
{

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

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

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

21
4. 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.

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.

22
Activity 3: Interfacing Bluetooth with Arduino

EN

VCC

GND

TX

RX

STATE

Components required

1. Bluetooth module - 1
2. Arduino UNO - 1
3. Arduino Uno Cable - 1
4. Jumper Wires M/F - 4

Procedure
1. Connect arduino board to your laptop/desktop using arduino cable.
2. Open arduino IDE.
3. Open program file, Go to File->Examples->Sparklebox_code->Select interfacing_Bluetooth_with_
Arduino.
4. Go to Tools->Board->Select arduino Uno.
5. Go to Tools->Port->Select COM(Arduino) port.
6. Click on the upload option.

Note:

Do no connect any wire to TX/RX pin of arduino while uploading the code/program.

23
Code:

Note:

You can see this code in your file, when you open this activity from arduino example folder.

#define ledPin 13
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}

void loop()
{
if(Serial.available())
{
char data=Serial.read();
if(data==’1’)
{
digitalWrite(ledPin,HIGH);
Serial.println(“LED is ON”);l
}
else if (data==’0’)
{
digitalWrite(ledPin,LOW);
Serial.println(“led is OFF”);
}
}
}

24
Program Overview

1. Define pin no where the led is connected to arduino board.


2. Define pinmode for the Led as OUTPUT.
3. Enable serial communication at 9600 baud rate.
4. If data is available, then read it and store it.
5. Check the stored data if it’s 1, then turn on the Led.
6. If it’s 0 then turn off the LED.

Note:

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

Code To Note
IF STATEMENT:
if(data==’1’)
If condition returns true then the statements inside the body of “if” are executed.
ELSE IF STATEMENT
else if(data==’0’)
The else..if statement is useful when you need to check multiple conditions within the program.

Connection Diagram:

Bluetooth Module Arduino Board


RXD -------------- TX
TXD -------------- RX
GND -------------- GND
VCC -------------- 5V

25
INTERFACING BETWEEN HARDWARE AND ANDROID BLUETOOTH APP:
Step 1: Do the connection as shown above. Led on the bluetooth module starts blinking..
Step 2: Download and install the “Arduino Bluetooth Control” App from the play store or app store.
Here is the Link to download the App:
https://play.google.com/store/apps/details?id=com.broxcode.arduinobluetoothfree

Step 3: Open your mobile bluetooth Settings->Turn On the Bluetooth.

Step 4: Select JDY-31-SPP or HC-05 device, it will start pairing that device, enter pairing pin as 1234

26
Step 5: After successfully paired then it will come under the Paired devices section.

Step 6: Open bluetooth App which was installed previously. Click on ↻ (Refresh) icon.

Step 7: You will get a paired device list like this, click on CONNECT option, it will try to connect with your
bluetooth device.

27
Step 8: If it’s connected. Click on Terminal and send commands like either 0 or 1, as per 0 and 1
commands Led output will change.

Output

You can see after sending 0 or 1 commands from the app, there is change in builtin led output on the
arduino board.

Troubleshooting

Issue: My code is not being uploaded?


Solution:
1. Every time try to upload the code before connections. Check whether board and port in arduino IDE is
selected or not.
Issue: In mobile bluetooth settings which bluetooth device needs to pair?
Solution: JDY-31-SPP or HC-05
Issue: The bluetooth is not connecting to the app?
Solution:
1. Make sure that bluetooth is powered ON and LED on the module is blinking. Also make sure your
connections are tight, loose jumpers may lead to improper connectivity.
2. Unpair the bluetooth from mobile settings and pair it again and now try to connect with the bluetooth
from the All in one App.

28
Issue: No data is coming on the serial monitor.
Solution: Check bluetooth TX/RX connections with arduino board.

Bluetooth Module Arduino Board


RXD -------------- TX
TXD -------------- RX
GND -------------- GND
VCC -------------- 5V

Challenge Task:

1. Try to control buzzer, turn ON/OFF the buzzer through your smartphone.

29
Activity 4: 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

Connection Diagram

Note:
You can get stepwise connection details inside the procedure to assemble the motion robot section.

30
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.
5. Go to Tools->Port->select com port(Arduino).
6. Click on the verify option.
7. Click on the upload option.

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);
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);

31
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//
}

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.

32
Procedure to Assemble motors and boards on chassis

Note:
Scan the QR Code/URL for support present on the back side of the manual select the voice controlled robot and
then select Build a Motion Robot to get the video reference file for assemble of the robot.

1. Take a MDF sheet of robotic chassis.

2. Separate all the parts from the chassis sheet.

33
3. Take two motor clamps and lock clamps along with the chassis as shown in the image.

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

34
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 the image.

Note:
Please make sure motor wires should come inside of the chassis while attaching motor support clamps.

35
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 the image.

36
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 the image.

37
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 the 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.

38
12. Take the cell holder, double sided tape a attach it on the bottom side of the chassis using double sided
tape as shown in the 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

39
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

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

Motor driver module Arduino(pins)


MC5(1st pin ) 11
MC5(2nd pin) 10
MC6(1st pin) 8
MC6(2nd pin) 9

1st pin
1st pin
2st pin 2st pin

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

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

19. Now turn ON the switch which is present on cell holder.


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.
43
Activity 5: Build a Voice Controlled 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) - 8
4. DC Motors - 2 9. MDF chassis Board - 1
5. Battery (AA Cell , 1.5V) - 4 10. Bluetooth Module - 1

Circuit Diagram
Bluetooth Arduino Board
RXD ---- pin no 3
TXD ---- pin no 2
GND ---- GND
VCC ---- 5V

44
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 the bluetooth
module on that model.
2. First remove batteries from the cell holder/turn off the switch on the cell holder.
3. Connect an arduino board to your laptop/desktop using an arduino cable.
4. Open arduino IDE.
5. Open program file. Go to File->Examples->Sparklebox_code->Select build_a_Voice_Controlled_
Robot.
6. Go to Tools->Board->select Arduino UNO.
7. Go to Tools->Port->select com port(Arduino Uno).
8. Click on the upload option and wait till done uploading.
9. Now disconnect the arduino board from your laptop/desktop.

Code:

#include <SoftwareSerial.h>
SoftwareSerial BT(2, 3); //TX, RX respetively
String readvoice;
#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() {
BT.begin(9600);
Serial.begin(9600);
pinMode(MLa, OUTPUT); // declaring Motors pin as output pin
pinMode(MLb, OUTPUT);

45
pinMode(MRa, OUTPUT);
pinMode(MRb, OUTPUT);
}
void loop() {
while (BT.available()) { //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = BT.read(); //Conduct a serial read
readvoice += c; //build the string- “forward”, “reverse”, “left” and “right”
}
if (readvoice.length() > 0) {
Serial.println(readvoice);
if(readvoice == “forward”) { //forward
digitalWrite(MLa, HIGH);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
delay(100);
}
else if(readvoice == “back”) { //backward
digitalWrite(MLa, LOW);
digitalWrite(MLb, HIGH);
digitalWrite(MRa, LOW);
digitalWrite(MRb, HIGH);
delay(100);
}
else if (readvoice == “turn right” ){ //Rightturn
digitalWrite(MLa, HIGH);

46
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay (100);
}
else if ( readvoice == “turn left”) { //LeftTurn
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MRa, HIGH);
digitalWrite(MRb, LOW);
delay (100);
}
else if (readvoice == “stop”) { //Stop
digitalWrite(MLa, LOW);
digitalWrite(MLb, LOW);
digitalWrite(MRa, LOW);
digitalWrite(MRb, LOW);
delay (100);
}
readvoice=””; }//Reset the variable
}

Program Overview
1. Define motor input pins which are going to connect with the arduino board.
2. Use software serial library for bluetooth communication.
3. Define the Tx/Rx pins for bluetooth data.
4. Enable serial communication.

47
5. Define pinmode for motor input pins.
6. If bluetooth data is available then read that data and store it in char(it is a datatype which can store
one character at a time.)
7. If the received character is ‘Forward’, then turn the motors in Forward direction.
8. If the received character is ‘Back’, then turn the motors in Reverse direction.
9. If the received character is ‘Left’, then turn the motors in Left direction.
10. If the received character is ‘Right’, then turn the motors in Right direction.
11. If the received character is ‘Stop’, then Stop the motors.

Code To Note

Note:

DIRECTIVE, INPUT OR OUTPUT, DIGITAL OUTPUT, functions , IF , ELSE IF statements are explained in
2nd and 3rd activity kindly refer to further activities.

Procedure to Assemble the Voice Controlled Robot

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

1. Take the chassis model which you used in previous activity with all connections as it is.
2. Take the bluetooth module and 4 male to female wires.

48
3. Place the bluetooth module on the chassis and do the wiring connections between arduino board an
bluetooth module.

Bluetooth Arduino Board


RXD ---- pin no 3
TXD ---- pin no 2
GND ---- GND
VCC ---- 5V

4. Now add the batteries in the cell holder.

5. Turn ON the switch on the cell holder.

49
6. Now connect the bluetooth module (HC-05) from your mobile phone. If connected to HC-05 message
received then click on voice control option.

7. Tap on the mic icon, speak one command like forward, back, turn left, turn right, stop.

8. Once the command is recognized, it will send automatically.

50
Output
According to your voice commands the robot will move. Robot will work with this following command only.

Commands to send: forward, back, turn left ,turn right, stop.

1. When you turn On the switch on the cell holder, the robot will not work immediately.
2. For that you have to connect bluetooth module to your mobile App, (please prefer 3rd activity for how
to connect bluetooth module with your mobile App).

Troubleshooting
Issue: Robot is not working.
Solution:
1. Make sure that switch is turned ON on the cell holder.
2. If the switch is turned ON, check whether the arduino board is getting powered (led on that
board should be turned ON if it is powered).
3. If not getting power check the wire connections once. Always connect batteries with correct
polarity in the cell holder, cell holder red wire should connect to + polarity and black wire to
the - polarity of the motor driver module.
4. If it’s connected properly, then check Bluetooth module connections and pair it first in your
mobile bluetooth settings.
5. Once it’s connected, the robot will move according to the commands (Through the Joystick
arrow) sent by the mobile App.

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

Scan the QR Code for Sparklebox Digital support

EXPERIENCING A PROBLEM NOT COVERED BY THE MANUAL?


We are constantly working to improve Sparklebox Robotic Kits experience.
To find a solutionVisit our Sparklebox support page at https://mysparklebox.com/robotic-faq.

Published by

K12 Techno Services Pvt. Ltd.


Bengaluru, Karnataka, India, 560022.

www.mysparklebox.com info@mysparklebox.com

You might also like