SlideShare a Scribd company logo
1 of 52
Arduino Bluetooth Mobile Robot
“Controlling Your Arduino Mobile Robot Using Android Bluetooth App”
Cytron Technologies Sdn Bhd - https://www.cytron.io
Version 2.0
...for dummy
Arduino Bluetooth Mobile Robot Module Content
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
No TOPIC DURATION
1. Mobile Robot Introduction 10 minutes
2. Getting Started with Maker UNO 30 minutes
3. Assemble the Mobile Robot 1 hour
4. Control the DC Motor 10 minutes
5. Set the Robot Movement 20 minutes
6. Serial Communication 20 minutes
7. Bluetooth HC-05 AT Command 10 minutes
8. Arduino BT Joystick Android App 20 minutes
9. Arduino Bluetooth Mobile Robot Let’s Play! 30 minutes
Mobile Robot Introduction
What is Mobile Robot?
Robots that can move around in a physical environment. Mobile robots are generally
controlled by software and use sensors and other gear to identify their surroundings.
In general, we can divide mobile robot into
● Autonomous
○ Robot moves automatically based on the sensors and other gear.
● Manual
○ Robot moves depend on the command received from the instructor.
Basic thing to develop mobile robot
1. Robot chassis.
2. Motor, motor driver and wheels.
3. Controller.
4. Battery.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Mobile Robot Introduction
List of mobile robot parts for this workshop
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Quantity Description
1 set 2WD Smart Robot Car Chassis
1 Maker UNO (Arduino Uno compatible)
1 L298N Dual H Bridge Motor/Stepper Driver
1 set Male to Female Jumper Wire
1 set Male to Male Jumper Wire
4 PCB Stand
1 sets 4 x AA Battery
1 Bluetooth Serial Transceiver HC-05
Getting Started with Maker UNO
What is Maker UNO?
Maker UNO is an Arduino Uno compatible board which is specially designed for
those who interested in learning electronic and programming for the first time.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
What is ?
Arduino is an open-source electronics
prototyping platform based on flexible,
easy-to-use hardware and software. It’s
intended for artists, designers,
hobbyists, and anyone interested in
creating interactive objects or
environments.
Getting Started with Maker UNO
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
On-board Piezo Buzzer
Piezo buzzer is connected to
pin 8 through slide switch.
On-board Programmable
Push Button
This button is connected to pin
2 without a pull up.
Reset Button
Press to restart program.
Mini Slide Switch
Switch to connect/disconnect
piezo buzzer to pin 8.
USB Micro B Connector
Main supply, program and
debug purpose.
On-board Series of LEDs
All digital pins is equipped with
LED. This LED can be controlled
or act as signal indicator.
USB to UART IC
Equipped with CH340G for USB
to UART conversion.
Main Microcontroller
Same as uC inside Arduino Uno
- ATmega328P.
Analog Input Pin
This pin can be used for reading
analog voltage.
Arduino ISP Pin
This pin can be used for SPI and
bootloader programming.
Serial Pin
Hardware Serial (UART) is
labeled with RX and TX pin.
Power Pin
USB 5V, regulated 3.3V 500mA
and GND.
Getting Started with Maker UNO
Arduino IDE
Arduino IDE is an open source software and it is free. Maker UNO can be
programmed using Arduino IDE. To get the latest version, you can download at
https://www.arduino.cc/en/Main/Software
Note: For Windows, we recommended to choose Windows Installer.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Getting Started with Maker UNO
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Menu Bar
Button Bar
Serial
Monitor
Sketch Name
Status Bar
IDE Output
Code Area
Board Name and Port
Getting Started with Maker UNO
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Verify
Compiles and approves your code. It will detect errors in syntax (e.g. missing semi colon
or parentheses).
Upload
Compiles and send your code to the Maker UNO. When you click it, you should see the
lights (labelled RX & TX) on your board blink rapidly.
New Sketch
This button opens up a new code window tab.
Open
This button will let you open an existing sketch.
Save
This saves the currently active sketch.
Serial Monitor
Open Serial Monitor.
Getting Started with Maker UNO
Maker UNO Driver
In order to make your Maker UNO board can be detected by PC/laptop, you need to
install CH340G driver. Download the driver from the following link.
● Windows - https://cdn.cytron.io/makeruno/CH341SER.EXE
● Mac - http://www.wch.cn/download/CH341SER_MAC_ZIP.html
● Linux - Normally is readily installed
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Assemble the Mobile Robot
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Assemble the Mobile Robot
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Wiring and connection
Wiring and connection
Assemble the Mobile Robot
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Maker UNO Pin Connection Maker UNO Pin Connection
0 NC 10 Motor Driver IN3
1 NC 11 Motor Driver IN4
2 Internal Push Button 12 NC
3 Bluetooth Transmit 13 NC
4 Bluetooth Receive A0 NC
5 Motor Driver ENA A1 NC
6 Motor Driver ENB A2 NC
7 Motor Driver IN1 A3 NC
8 Internal Buzzer A4 NC
9 Motor Driver IN2 A5 NC
Control the DC Motor
What is DC Motor?
Any of a class of rotary electrical machines that converts direct current electrical
energy into mechanical energy. There have 2 types if DC motor:
1. Brush
2. Brushless
How brush DC motor works?
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Control the DC Motor
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
#define BUTTON 2
#define L298N_ENA 5
#define L298N_ENB 6
#define L298N_IN1 7
#define L298N_IN2 9
#define L298N_IN3 10
#define L298N_IN4 11
void setup()
{
pinMode(BUTTON, INPUT_PULLUP);
pinMode(L298N_ENA, OUTPUT);
pinMode(L298N_ENB, OUTPUT);
pinMode(L298N_IN1, OUTPUT);
pinMode(L298N_IN2, OUTPUT);
pinMode(L298N_IN3, OUTPUT);
pinMode(L298N_IN4, OUTPUT);
}
Define pin 2 as internal push button.
Define pin 5 as motor driver ENA.
Define pin 6 as motor driver ENB.
Define pin 7 as motor driver IN1.
Define pin 9 as motor driver IN2.
Define pin 10 as motor driver IN3.
Define pin 11 as motor driver IN4.
Set push button as input with internal pull up.
Set motor driver ENA as output.
Set motor driver ENB as output.
Set motor driver IN1 as output.
Set motor driver IN2 as output.
Set motor driver IN3 as output.
Set motor driver IN4 as output.
Moving DC Motor: Write and Upload this code to your Maker UNO.
Control the DC Motor
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void loop()
{
if (digitalRead(BUTTON) == LOW) {
digitalWrite(L298N_ENA, HIGH);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
digitalWrite(L298N_ENB, HIGH);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
else {
digitalWrite(L298N_ENA, LOW);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, LOW);
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, LOW);
}
}
If button is pressed, move the motor.
Enable channel A
Set the direction for motor 1
Enable channel B
Set the direction for motor 2
If not pressed, both motors will stop
Disable channel A
Disable channel B
Moving DC Motor: Write and Upload this code to your Maker UNO.
Control the DC Motor
Result:
When the push button is pressed, both motors will move to certain direction. So
how to change the motor direction?
This table shows the relationship between driver signal at channel A and motor 1
direction. Same applies to channel B and motor 2.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Motor 1 ENA IN1 IN2
Stop LOW Don’t care Don’t care
Clockwise HIGH LOW HIGH
Counter Clockwise HIGH HIGH LOW
Brake
HIGH HIGH HIGH
HIGH LOW LOW
Control the DC Motor
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
if (digitalRead(BUTTON) == LOW) {
analogWrite(L298N_ENA, 200);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
analogWrite(L298N_ENB, 200);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
If button is pressed, move the motor.
Set voltage at pin ENA to ~4V (200/255 x 5V)
Set the direction for motor 1
Set voltage at pin ENB to ~4V (200/255 x 5V)
Set the direction for motor 2
Controlling Motor Speed: You can control the motor speed by applying different
voltage at enable pin by using analogWrite() function.
For example:
Set the Robot Movement
Basic Mobile Robot Movement
You already know how to control the motor. By combining the movement of both
motors, you can set the robot movement!
Below is the basic movement of the robot:
1. Stop/Brake
2. Forward
3. Reverse
4. Turn Left
5. Turn Right
Note: Everyone will have a different set of program to produce the same
movement. This is because we don’t have the same connection especially on
motor terminal. So find yours!
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
How to
move?
Which direction
I need to rotate
so my body will
move forward?
???
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Robot Movement: FORWARD
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Robot Movement: REVERSE
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Robot Movement: TURN RIGHT
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Robot Movement: TURN LEFT
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotForward(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, HIGH);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
void robotReverse(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot move forward, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to move forward
Enable channel B (Left motor)
Set the direction for motor 2 to move forward
Function for robot go reverse, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to reverse
Enable channel B (Left motor)
Set the direction for motor 2 to reverse
Create function: Once you have finalize your robot movement, create function for
each movement - forward, reverse, turn right, turn left and stop.
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotTurnRight(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
void robotTurnLeft(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, HIGH);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot turn right, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to go reverse
Enable channel B (Left motor)
Set the direction for motor 2 to move forward
Function for robot turn left, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to move forward
Enable channel B (Left motor)
Set the direction for motor 2 to reverse
Create function: Once you have finalize your robot movement, create function for
each movement - forward, reverse, turn right, turn left and stop.
Set the Robot Movement
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotStop()
{
digitalWrite(L298N_ENA, LOW);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, LOW);
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, LOW);
}
void robotBrake()
{
digitalWrite(L298N_ENA, HIGH);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, HIGH);
digitalWrite(L298N_ENB, HIGH);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot stop
Enable channel A (Right motor)
Motor 1 stop
Enable channel B (Left motor)
Motor 2 stop
Function for robot brake
Enable channel A (Right motor)
Motor 1 brake
Enable channel B (Left motor)
Motor 2 brake
Create function: Once you have finalize your robot movement, create function for
each movement - forward, reverse, turn right, turn left and stop.
Serial Communication
What is Serial Communication?
It is a most popular communication protocol (also known as UART) used to
communicate between the Arduino board and a computer or other devices.
● Bluetooth: HC-05, HC-06.
● GSM: SIM900A, SIM800L.
● WiFi module: ESP8266.
● RFid reader: 125kHz, MiFare.
● GPS, RF module, and more...
Hardware Serial
It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via
USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital
input or output.
Note: Please disconnect pin 0 and 1 during uploading sketch.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Serial Communication
Software Serial
Due to limited number of hardware serial (only at pin 0 and 1) in Arduino Uno,
SoftwareSerial library has been developed to allow serial communication on other
digital pins of the Arduino Uno board.
However, there still have limitation on SoftwareSerial library for Arduino Uno:
● If using multiple software serial ports, only one can receive data at a time.
● Current maximum RX speed is 57600 bps.
● RX doesn't work on pin 13.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Bluetooth HC-05 AT Command
What is AT Command?
AT commands are instructions used to control a modem. AT is the abbreviation of
ATtention. Every command line starts with "AT" or "at", as a prefix that informs the
modem about the start of a command line.
Bluetooth HC-05 AT Command
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
AT Command Description
AT Check the connection.
AT+VERSION Check bluetooth version. For example, it returned VERSION:3.0-20170609
AT+NAME=.... Set bluetooth name. For example AT+NAME=Maker UNO
AT+PSWD="...." Set bluetooth pin number. For example AT+PSWD=”8888”
AT+ORGL Restore factory setting
Bluetooth HC-05 AT Command
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
#include <SoftwareSerial.h>
SoftwareSerial HC05Serial(3, 4);
void setup()
{
Serial.begin(9600);
HC05Serial.begin(38400);
}
void loop()
{
if (Serial.available()) {
HC05Serial.write(Serial.read());
}
if (HC05Serial.available()) {
Serial.write(HC05Serial.read());
}
}
Include SoftwareSerial function
Set pin 3 as RX and 4 as TX
Initialize Serial with 9600bps
Initialize bluetooth serial with 38400bps
If AT command received from Serial Monitor
Send AT command to bluetooth
If response received from bluetooth
Display on Serial Monitor
Upload this sketch to Maker UNO.
Bluetooth HC-05 AT Command
Now set your own name and pin number at your bluetooth module. For example:
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Send Received
AT OK
AT+VERSION
VERSION:3.0-20170609
OK
AT+NAME=Maker UNO OK
AT+PSWD=”8888” OK
Bluetooth HC-05 AT Command
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
To enter AT command mode in HC-05 bluetooth module, please follow these
steps:
1. Turn off the bluetooth module.
2. Press and hold button on the bluetooth module.
3. Turn on the bluetooth module.
4. Release the button.
Open Serial Monitor and set to
9600 baud and Both NL & CR.
Next, configure bluetooth with
AT command.
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
#include <SoftwareSerial.h>
SoftwareSerial HC05Serial(3, 4);
void setup()
{
Serial.begin(9600);
HC05Serial.begin(9600);
}
void loop()
{
if (Serial.available()) {
HC05Serial.write(Serial.read());
}
if (HC05Serial.available()) {
Serial.write(HC05Serial.read());
}
}
Include SoftwareSerial function
Set pin 3 as RX and 4 as TX
Initialize Serial with 9600bps
Initialize bluetooth serial with 9600bps
If AT command received from Serial Monitor
Send AT command to bluetooth
If response received from bluetooth
Display on Serial Monitor
Upload this sketch to Maker UNO. Then, we can see the status of the button on the
Arduino BT Joystick app at the Serial Monitor when the bluetooth is connected.
Arduino BT Joystick Android App
In this workshop, we will use Arduino BT Joystick Free. Why? Because it is free,
easy to use and have a nice layout. So let’s install and open it.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
FYI, Arduino BT Joystick Free is no longer available in Play Store. But don’t worry,
we have prepared the APK file. You can download here (click using your phone)
from Google Drive.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
Finish download, click on the installer (APK) file. By default your phone setting is
not allowed any installation except from Play Store. Unless you’re sure the
sources, you can allow the installation on your phone setting.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
Proceed with the installation. Once complete, the app icon will appear on your
phone - home screen. To open it, just tap on the icon as usual.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
Now we need to configure a bit on
this app.
1. Click on the Menu and choose
Settings.
1. Click Define the send delay.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
3. Update value in Define the send
delay (ms) from 20 to 200. Click
OK and Save.
3. It will return to the main screen.
Now click CONNECT.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
5. Choose your bluetooth name.
Make sure your bluetooth name
is unique. Else, other participant
will connect to your bluetooth. :)
5. Put your bluetooth pin number
and click OK.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
7. If the connection successful, the
CONNECT button will update to
DISCONNECT. If you click on the
DISCONNECT button, it will
disconnect the bluetooth
connection.
7. Then, if you notice, there have a
set of data display on Serial
Monitor (during bluetooth is
connected). This is the status of
the button on the Arduino BT
Joystick app.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
Every 200ms (set in Define the send delay), this app will send a set of data as
shown in the picture above. If no key have been pressed, it sends #b=0#.
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
#include <SoftwareSerial.h>
SoftwareSerial HC05Serial(3, 4);
char inChar;
String inString;
void setup()
{
Serial.begin(9600);
HC05Serial.begin(9600);
}
Include SoftwareSerial function
Set pin 3 as RX and 4 as TX
Global char variable for inChar
Global string variable called inString
Initialize Serial with 9600bps
Initialize bluetooth serial with 9600bps
After knowing the data set, now we need to grab the data and do comparison in
the program, so that we can make specific action for specific key.
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void loop()
{
if (HC05Serial.available()) {
delay(100);
inString = "";
while (HC05Serial.available()) {
inChar = HC05Serial.read();
inString = inString + inChar;
}
if (inString == "#b=0#") {
Serial.println("None");
}
else if (inString == "#b=1#") {
Serial.println("Up");
}
}
}
If bluetooth received the data from the app
Wait for 100ms so that all the data is received
Clear inString variable
While the data set is available
Read and store to inChar variable
Combined characters to form a single string
Do comparison, if inString = "#b=0#"
Print on Serial Monitor “None”
Do comparison, if inString = "#b=1#"
Print on Serial Monitor “Up”
Arduino Bluetooth Mobile Robot
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
This is the final stage to create Arduino Bluetooth Mobile Robot. Make sure the
previous chapters is working.
1. Set the robot movement together
with functions.
2. Configure bluetooth using AT
command (name, pin #).
3. Read data set from the app.
4. Compare and do specific action.
5. Now, combine no 1 and 4.
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
#define RX 3
#define TX 4
#include <SoftwareSerial.h>
SoftwareSerial HC05Serial(RX, TX);
#define BUTTON 2
#define L298N_ENA 5
#define L298N_ENB 6
#define L298N_IN1 7
#define L298N_IN2 9
#define L298N_IN3 10
#define L298N_IN4 11
char inChar;
String inString;
Define pin 3 as received pin = HC05 TX.
Define pin 4 as transmit pin = HC05 RX.
Include SoftwareSerial function
Set pin 3 as RX and 4 as TX
Define pin 2 as internal push button.
Define pin 5 as motor driver ENA.
Define pin 6 as motor driver ENB.
Define pin 7 as motor driver IN1.
Define pin 9 as motor driver IN2.
Define pin 10 as motor driver IN3.
Define pin 11 as motor driver IN4.
Global char variable for inChar
Global string variable called inString
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void setup()
{
Serial.begin(9600);
HC05Serial.begin(9600);
pinMode(BUTTON, INPUT_PULLUP);
pinMode(L298N_ENA, OUTPUT);
pinMode(L298N_ENB, OUTPUT);
pinMode(L298N_IN1, OUTPUT);
pinMode(L298N_IN2, OUTPUT);
pinMode(L298N_IN3, OUTPUT);
pinMode(L298N_IN4, OUTPUT);
}
Initialize Serial with 9600bps
Initialize bluetooth serial with 9600bps
Set push button as input with internal pull up.
Set motor driver ENA as output.
Set motor driver ENB as output.
Set motor driver IN1 as output.
Set motor driver IN2 as output.
Set motor driver IN3 as output.
Set motor driver IN4 as output.
BT JoysArduino tick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void loop()
{
if (HC05Serial.available()) {
delay(100);
inString = "";
while (HC05Serial.available()) {
inChar = HC05Serial.read();
inString = inString + inChar;
}
if (inString == "#b=0#") {
robotStop();
} else if (inString == "#b=1#") {
robotForward(200);
} else if (inString == "#b=2#") {
robotReverse(200);
} else if (inString == "#b=3#") {
robotTurnLeft(150);
} else if (inString == "#b=4#") {
robotTurnRight(150);
}
}
}
If bluetooth received the data from the app
Wait for 100ms so that all the data is received
Clear inString variable
While the data set is available
Read and store to inChar variable
Combined characters to form a single string
If inString = "#b=0#"
Robot stop
If inString = "#b=1#"
Robot move forward with PWM 200
If inString = "#b=2#"
Robot go reverse with PWM 200
If inString = "#b=3#"
Robot turn left with PWM 150
If inString = "#b=4#"
Robot turn right with PWM 150
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotForward(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, HIGH);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
void robotReverse(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot move forward, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to move forward
Enable channel B (Left motor)
Set the direction for motor 2 to move forward
Function for robot go reverse, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to reverse
Enable channel B (Left motor)
Set the direction for motor 2 to reverse
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotTurnRight(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW);
}
void robotTurnLeft(int robotSpeed)
{
analogWrite(L298N_ENA, robotSpeed);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, HIGH);
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot turn right, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to go reverse
Enable channel B (Left motor)
Set the direction for motor 2 to move forward
Function for robot turn left, speed = 0 - 255
Enable channel A (Right motor)
Set the direction for motor 1 to move forward
Enable channel B (Left motor)
Set the direction for motor 2 to reverse
Arduino BT Joystick Android App
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
void robotStop()
{
digitalWrite(L298N_ENA, LOW);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, LOW);
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, LOW);
}
void robotBrake()
{
digitalWrite(L298N_ENA, HIGH);
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, HIGH);
digitalWrite(L298N_ENB, HIGH);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, HIGH);
}
Function for robot stop
Enable channel A (Right motor)
Motor 1 stop
Enable channel B (Left motor)
Motor 2 stop
Function for robot brake
Enable channel A (Right motor)
Motor 1 brake
Enable channel B (Left motor)
Motor 2 brake
End of Workshop
Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
Thank you and Let’s Play!
Q & A Session

More Related Content

What's hot

Servo Based 5 Axis Robotic Arm Project Report
Servo Based 5 Axis Robotic Arm Project ReportServo Based 5 Axis Robotic Arm Project Report
Servo Based 5 Axis Robotic Arm Project ReportRobo India
 
IRJET- IoT Color based Product Sorting Machine
IRJET- IoT Color based Product Sorting MachineIRJET- IoT Color based Product Sorting Machine
IRJET- IoT Color based Product Sorting MachineIRJET Journal
 
Bluetooth Controlled Robot
Bluetooth Controlled RobotBluetooth Controlled Robot
Bluetooth Controlled RobotPankaj Rai
 
Voice controlled spy robot for security system
Voice controlled spy robot for security systemVoice controlled spy robot for security system
Voice controlled spy robot for security systemMayank Prajapati
 
Bluetooth controlled android car
Bluetooth controlled android car Bluetooth controlled android car
Bluetooth controlled android car doaamarzook
 
Android controlled robot
Android controlled robotAndroid controlled robot
Android controlled robotBen Johnke
 
Bluetooth controlled robot using arduino uno and HC-05
Bluetooth controlled robot using arduino uno and HC-05Bluetooth controlled robot using arduino uno and HC-05
Bluetooth controlled robot using arduino uno and HC-05MuhammadUsman1709
 
Bluetooth Controlled Robot/Car
Bluetooth Controlled Robot/CarBluetooth Controlled Robot/Car
Bluetooth Controlled Robot/CarVarun A M
 
Automatic railway gate control using arduino uno
Automatic railway gate control using arduino unoAutomatic railway gate control using arduino uno
Automatic railway gate control using arduino unoselvalakshmi24
 
Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Diwash Kapil Chettri
 
Automatic room temperature control
Automatic room temperature controlAutomatic room temperature control
Automatic room temperature controldebabratrath
 
Line follower robot
Line follower robotLine follower robot
Line follower robotPriya Hada
 
Final report obstacle avoiding roboat
Final report obstacle avoiding roboatFinal report obstacle avoiding roboat
Final report obstacle avoiding roboatShubham Thakur
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following RobotDivay Khatri
 
Electrical machines I (II-EEE)
Electrical machines I (II-EEE)Electrical machines I (II-EEE)
Electrical machines I (II-EEE)betasam
 
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...MD. Anamul Haque
 

What's hot (20)

Servo Based 5 Axis Robotic Arm Project Report
Servo Based 5 Axis Robotic Arm Project ReportServo Based 5 Axis Robotic Arm Project Report
Servo Based 5 Axis Robotic Arm Project Report
 
IRJET- IoT Color based Product Sorting Machine
IRJET- IoT Color based Product Sorting MachineIRJET- IoT Color based Product Sorting Machine
IRJET- IoT Color based Product Sorting Machine
 
Industri robotik
Industri robotik Industri robotik
Industri robotik
 
Bluetooth Controlled Robot
Bluetooth Controlled RobotBluetooth Controlled Robot
Bluetooth Controlled Robot
 
Voice controlled spy robot for security system
Voice controlled spy robot for security systemVoice controlled spy robot for security system
Voice controlled spy robot for security system
 
Bluetooth controlled android car
Bluetooth controlled android car Bluetooth controlled android car
Bluetooth controlled android car
 
Android controlled robot
Android controlled robotAndroid controlled robot
Android controlled robot
 
Bluetooth controlled robot using arduino uno and HC-05
Bluetooth controlled robot using arduino uno and HC-05Bluetooth controlled robot using arduino uno and HC-05
Bluetooth controlled robot using arduino uno and HC-05
 
Omron ladder programming
Omron ladder programmingOmron ladder programming
Omron ladder programming
 
Bluetooth Controlled Robot/Car
Bluetooth Controlled Robot/CarBluetooth Controlled Robot/Car
Bluetooth Controlled Robot/Car
 
Automatic railway gate control using arduino uno
Automatic railway gate control using arduino unoAutomatic railway gate control using arduino uno
Automatic railway gate control using arduino uno
 
Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...
 
Automatic room temperature control
Automatic room temperature controlAutomatic room temperature control
Automatic room temperature control
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Servo motor drive
Servo motor driveServo motor drive
Servo motor drive
 
Final report obstacle avoiding roboat
Final report obstacle avoiding roboatFinal report obstacle avoiding roboat
Final report obstacle avoiding roboat
 
23491369 litar-elektronik
23491369 litar-elektronik23491369 litar-elektronik
23491369 litar-elektronik
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following Robot
 
Electrical machines I (II-EEE)
Electrical machines I (II-EEE)Electrical machines I (II-EEE)
Electrical machines I (II-EEE)
 
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...
Android controlled Microcontroller (Arduino) based Motorized Wheelchair for H...
 

Similar to Arduino bt mobile robot r2.0

Development Of An Internet Controlled Surveillance Mobile Robot Part1
Development Of An Internet Controlled Surveillance Mobile Robot Part1Development Of An Internet Controlled Surveillance Mobile Robot Part1
Development Of An Internet Controlled Surveillance Mobile Robot Part1mimi
 
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docx
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docxDIGITAL LOGIC DESIGN (1) PROJECT REPORT.docx
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docxRafayNaveed4
 
Design and Mechanism ofControlling a Robotic ArmIntroduction.docx
Design and Mechanism ofControlling a Robotic ArmIntroduction.docxDesign and Mechanism ofControlling a Robotic ArmIntroduction.docx
Design and Mechanism ofControlling a Robotic ArmIntroduction.docxcarolinef5
 
Obstacle avoiding Robot
Obstacle avoiding RobotObstacle avoiding Robot
Obstacle avoiding RobotRasheed Khan
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724PAVINRAJ5
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino AMIT SANPUI
 
Full details of implementation of flying internet balloon
Full details of implementation of flying internet balloonFull details of implementation of flying internet balloon
Full details of implementation of flying internet balloonANTONY SEBATIAN
 
Mechatronic Workshop Arduino
Mechatronic Workshop ArduinoMechatronic Workshop Arduino
Mechatronic Workshop ArduinoArifKamaruddin1
 
Industrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicIndustrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicRobocraze
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetoothShishupal03012015
 
IoT Based Solar Water Pump Controller
IoT Based Solar Water Pump ControllerIoT Based Solar Water Pump Controller
IoT Based Solar Water Pump ControllerIJSRED
 
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdf
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdfAdvanced View Arduino Projects List _ Use Arduino for Projects {4}.pdf
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdfWiseNaeem
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbookFelipe Belarmino
 
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...IRJET Journal
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduinoIkram Arshad
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)Brian Huang
 

Similar to Arduino bt mobile robot r2.0 (20)

Development Of An Internet Controlled Surveillance Mobile Robot Part1
Development Of An Internet Controlled Surveillance Mobile Robot Part1Development Of An Internet Controlled Surveillance Mobile Robot Part1
Development Of An Internet Controlled Surveillance Mobile Robot Part1
 
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docx
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docxDIGITAL LOGIC DESIGN (1) PROJECT REPORT.docx
DIGITAL LOGIC DESIGN (1) PROJECT REPORT.docx
 
Design and Mechanism ofControlling a Robotic ArmIntroduction.docx
Design and Mechanism ofControlling a Robotic ArmIntroduction.docxDesign and Mechanism ofControlling a Robotic ArmIntroduction.docx
Design and Mechanism ofControlling a Robotic ArmIntroduction.docx
 
home automation digital
home automation digitalhome automation digital
home automation digital
 
Obstacle avoiding Robot
Obstacle avoiding RobotObstacle avoiding Robot
Obstacle avoiding Robot
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino
 
Full details of implementation of flying internet balloon
Full details of implementation of flying internet balloonFull details of implementation of flying internet balloon
Full details of implementation of flying internet balloon
 
Mechatronic Workshop Arduino
Mechatronic Workshop ArduinoMechatronic Workshop Arduino
Mechatronic Workshop Arduino
 
Industrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicIndustrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder Logic
 
Ppt
PptPpt
Ppt
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetooth
 
IoT Based Solar Water Pump Controller
IoT Based Solar Water Pump ControllerIoT Based Solar Water Pump Controller
IoT Based Solar Water Pump Controller
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdf
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdfAdvanced View Arduino Projects List _ Use Arduino for Projects {4}.pdf
Advanced View Arduino Projects List _ Use Arduino for Projects {4}.pdf
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbook
 
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
IRJET- Automated Elevator-An Attentive Elevator to Elevate using Speech Recog...
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduino
 
Arduino intro.pptx
Arduino intro.pptxArduino intro.pptx
Arduino intro.pptx
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)
 

More from Fajar Baskoro

Generasi Terampil Digital Skill-2023.pptx
Generasi Terampil Digital Skill-2023.pptxGenerasi Terampil Digital Skill-2023.pptx
Generasi Terampil Digital Skill-2023.pptxFajar Baskoro
 
Cara Membuat Kursus Online Wordpress-tutorstarter
Cara Membuat Kursus Online Wordpress-tutorstarterCara Membuat Kursus Online Wordpress-tutorstarter
Cara Membuat Kursus Online Wordpress-tutorstarterFajar Baskoro
 
PPT-Kick Off Double Track 2024 melaksanakan Festival Ramadhan
PPT-Kick Off Double Track 2024 melaksanakan Festival RamadhanPPT-Kick Off Double Track 2024 melaksanakan Festival Ramadhan
PPT-Kick Off Double Track 2024 melaksanakan Festival RamadhanFajar Baskoro
 
Buku Inovasi 2023 - 2024 konsep capaian KUS
Buku Inovasi 2023 - 2024 konsep capaian  KUSBuku Inovasi 2023 - 2024 konsep capaian  KUS
Buku Inovasi 2023 - 2024 konsep capaian KUSFajar Baskoro
 
Pemaparan Sosialisasi Program Dual Track 2024.pptx
Pemaparan Sosialisasi Program Dual Track 2024.pptxPemaparan Sosialisasi Program Dual Track 2024.pptx
Pemaparan Sosialisasi Program Dual Track 2024.pptxFajar Baskoro
 
Executive Millennial Entrepreneur Award 2023-1a-1.pdf
Executive Millennial Entrepreneur Award  2023-1a-1.pdfExecutive Millennial Entrepreneur Award  2023-1a-1.pdf
Executive Millennial Entrepreneur Award 2023-1a-1.pdfFajar Baskoro
 
1-Executive Millennial Entrepreneur Award 2023-1-cetak.pptx
1-Executive Millennial Entrepreneur Award  2023-1-cetak.pptx1-Executive Millennial Entrepreneur Award  2023-1-cetak.pptx
1-Executive Millennial Entrepreneur Award 2023-1-cetak.pptxFajar Baskoro
 
Executive Millennial Entrepreneur Award 2023-1.pptx
Executive Millennial Entrepreneur Award  2023-1.pptxExecutive Millennial Entrepreneur Award  2023-1.pptx
Executive Millennial Entrepreneur Award 2023-1.pptxFajar Baskoro
 
Pemrograman Mobile - JetPack Compose1.pptx
Pemrograman Mobile - JetPack Compose1.pptxPemrograman Mobile - JetPack Compose1.pptx
Pemrograman Mobile - JetPack Compose1.pptxFajar Baskoro
 
Evaluasi KPP Program Dual Track Provinsi Kaltim
Evaluasi KPP Program Dual Track Provinsi KaltimEvaluasi KPP Program Dual Track Provinsi Kaltim
Evaluasi KPP Program Dual Track Provinsi KaltimFajar Baskoro
 
foto tenda digital skill program dari sekolah
foto tenda digital skill program dari sekolahfoto tenda digital skill program dari sekolah
foto tenda digital skill program dari sekolahFajar Baskoro
 
Meraih Peluang di Gig Economy yang cocok bagi remaja
Meraih Peluang di Gig Economy yang cocok bagi remajaMeraih Peluang di Gig Economy yang cocok bagi remaja
Meraih Peluang di Gig Economy yang cocok bagi remajaFajar Baskoro
 
Membangun aplikasi mobile dengan Appsheet
Membangun aplikasi mobile dengan AppsheetMembangun aplikasi mobile dengan Appsheet
Membangun aplikasi mobile dengan AppsheetFajar Baskoro
 
Transition education to employment.pdf
Transition education to employment.pdfTransition education to employment.pdf
Transition education to employment.pdfFajar Baskoro
 

More from Fajar Baskoro (20)

Generasi Terampil Digital Skill-2023.pptx
Generasi Terampil Digital Skill-2023.pptxGenerasi Terampil Digital Skill-2023.pptx
Generasi Terampil Digital Skill-2023.pptx
 
Cara Membuat Kursus Online Wordpress-tutorstarter
Cara Membuat Kursus Online Wordpress-tutorstarterCara Membuat Kursus Online Wordpress-tutorstarter
Cara Membuat Kursus Online Wordpress-tutorstarter
 
PPT-Kick Off Double Track 2024 melaksanakan Festival Ramadhan
PPT-Kick Off Double Track 2024 melaksanakan Festival RamadhanPPT-Kick Off Double Track 2024 melaksanakan Festival Ramadhan
PPT-Kick Off Double Track 2024 melaksanakan Festival Ramadhan
 
Buku Inovasi 2023 - 2024 konsep capaian KUS
Buku Inovasi 2023 - 2024 konsep capaian  KUSBuku Inovasi 2023 - 2024 konsep capaian  KUS
Buku Inovasi 2023 - 2024 konsep capaian KUS
 
Pemaparan Sosialisasi Program Dual Track 2024.pptx
Pemaparan Sosialisasi Program Dual Track 2024.pptxPemaparan Sosialisasi Program Dual Track 2024.pptx
Pemaparan Sosialisasi Program Dual Track 2024.pptx
 
Executive Millennial Entrepreneur Award 2023-1a-1.pdf
Executive Millennial Entrepreneur Award  2023-1a-1.pdfExecutive Millennial Entrepreneur Award  2023-1a-1.pdf
Executive Millennial Entrepreneur Award 2023-1a-1.pdf
 
1-Executive Millennial Entrepreneur Award 2023-1-cetak.pptx
1-Executive Millennial Entrepreneur Award  2023-1-cetak.pptx1-Executive Millennial Entrepreneur Award  2023-1-cetak.pptx
1-Executive Millennial Entrepreneur Award 2023-1-cetak.pptx
 
Executive Millennial Entrepreneur Award 2023-1.pptx
Executive Millennial Entrepreneur Award  2023-1.pptxExecutive Millennial Entrepreneur Award  2023-1.pptx
Executive Millennial Entrepreneur Award 2023-1.pptx
 
Pemrograman Mobile - JetPack Compose1.pptx
Pemrograman Mobile - JetPack Compose1.pptxPemrograman Mobile - JetPack Compose1.pptx
Pemrograman Mobile - JetPack Compose1.pptx
 
Evaluasi KPP Program Dual Track Provinsi Kaltim
Evaluasi KPP Program Dual Track Provinsi KaltimEvaluasi KPP Program Dual Track Provinsi Kaltim
Evaluasi KPP Program Dual Track Provinsi Kaltim
 
foto tenda digital skill program dari sekolah
foto tenda digital skill program dari sekolahfoto tenda digital skill program dari sekolah
foto tenda digital skill program dari sekolah
 
Meraih Peluang di Gig Economy yang cocok bagi remaja
Meraih Peluang di Gig Economy yang cocok bagi remajaMeraih Peluang di Gig Economy yang cocok bagi remaja
Meraih Peluang di Gig Economy yang cocok bagi remaja
 
Membangun aplikasi mobile dengan Appsheet
Membangun aplikasi mobile dengan AppsheetMembangun aplikasi mobile dengan Appsheet
Membangun aplikasi mobile dengan Appsheet
 
epl1.pdf
epl1.pdfepl1.pdf
epl1.pdf
 
user.docx
user.docxuser.docx
user.docx
 
Dtmart.pptx
Dtmart.pptxDtmart.pptx
Dtmart.pptx
 
DualTrack-2023.pptx
DualTrack-2023.pptxDualTrack-2023.pptx
DualTrack-2023.pptx
 
BADGE.pptx
BADGE.pptxBADGE.pptx
BADGE.pptx
 
womenatwork.pdf
womenatwork.pdfwomenatwork.pdf
womenatwork.pdf
 
Transition education to employment.pdf
Transition education to employment.pdfTransition education to employment.pdf
Transition education to employment.pdf
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Arduino bt mobile robot r2.0

  • 1. Arduino Bluetooth Mobile Robot “Controlling Your Arduino Mobile Robot Using Android Bluetooth App” Cytron Technologies Sdn Bhd - https://www.cytron.io Version 2.0 ...for dummy
  • 2. Arduino Bluetooth Mobile Robot Module Content Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io No TOPIC DURATION 1. Mobile Robot Introduction 10 minutes 2. Getting Started with Maker UNO 30 minutes 3. Assemble the Mobile Robot 1 hour 4. Control the DC Motor 10 minutes 5. Set the Robot Movement 20 minutes 6. Serial Communication 20 minutes 7. Bluetooth HC-05 AT Command 10 minutes 8. Arduino BT Joystick Android App 20 minutes 9. Arduino Bluetooth Mobile Robot Let’s Play! 30 minutes
  • 3. Mobile Robot Introduction What is Mobile Robot? Robots that can move around in a physical environment. Mobile robots are generally controlled by software and use sensors and other gear to identify their surroundings. In general, we can divide mobile robot into ● Autonomous ○ Robot moves automatically based on the sensors and other gear. ● Manual ○ Robot moves depend on the command received from the instructor. Basic thing to develop mobile robot 1. Robot chassis. 2. Motor, motor driver and wheels. 3. Controller. 4. Battery. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 4. Mobile Robot Introduction List of mobile robot parts for this workshop Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Quantity Description 1 set 2WD Smart Robot Car Chassis 1 Maker UNO (Arduino Uno compatible) 1 L298N Dual H Bridge Motor/Stepper Driver 1 set Male to Female Jumper Wire 1 set Male to Male Jumper Wire 4 PCB Stand 1 sets 4 x AA Battery 1 Bluetooth Serial Transceiver HC-05
  • 5. Getting Started with Maker UNO What is Maker UNO? Maker UNO is an Arduino Uno compatible board which is specially designed for those who interested in learning electronic and programming for the first time. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io What is ? Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
  • 6. Getting Started with Maker UNO Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io On-board Piezo Buzzer Piezo buzzer is connected to pin 8 through slide switch. On-board Programmable Push Button This button is connected to pin 2 without a pull up. Reset Button Press to restart program. Mini Slide Switch Switch to connect/disconnect piezo buzzer to pin 8. USB Micro B Connector Main supply, program and debug purpose. On-board Series of LEDs All digital pins is equipped with LED. This LED can be controlled or act as signal indicator. USB to UART IC Equipped with CH340G for USB to UART conversion. Main Microcontroller Same as uC inside Arduino Uno - ATmega328P. Analog Input Pin This pin can be used for reading analog voltage. Arduino ISP Pin This pin can be used for SPI and bootloader programming. Serial Pin Hardware Serial (UART) is labeled with RX and TX pin. Power Pin USB 5V, regulated 3.3V 500mA and GND.
  • 7. Getting Started with Maker UNO Arduino IDE Arduino IDE is an open source software and it is free. Maker UNO can be programmed using Arduino IDE. To get the latest version, you can download at https://www.arduino.cc/en/Main/Software Note: For Windows, we recommended to choose Windows Installer. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 8. Getting Started with Maker UNO Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Menu Bar Button Bar Serial Monitor Sketch Name Status Bar IDE Output Code Area Board Name and Port
  • 9. Getting Started with Maker UNO Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Verify Compiles and approves your code. It will detect errors in syntax (e.g. missing semi colon or parentheses). Upload Compiles and send your code to the Maker UNO. When you click it, you should see the lights (labelled RX & TX) on your board blink rapidly. New Sketch This button opens up a new code window tab. Open This button will let you open an existing sketch. Save This saves the currently active sketch. Serial Monitor Open Serial Monitor.
  • 10. Getting Started with Maker UNO Maker UNO Driver In order to make your Maker UNO board can be detected by PC/laptop, you need to install CH340G driver. Download the driver from the following link. ● Windows - https://cdn.cytron.io/makeruno/CH341SER.EXE ● Mac - http://www.wch.cn/download/CH341SER_MAC_ZIP.html ● Linux - Normally is readily installed Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 11. Assemble the Mobile Robot Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 12. Assemble the Mobile Robot Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Wiring and connection
  • 13. Wiring and connection Assemble the Mobile Robot Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Maker UNO Pin Connection Maker UNO Pin Connection 0 NC 10 Motor Driver IN3 1 NC 11 Motor Driver IN4 2 Internal Push Button 12 NC 3 Bluetooth Transmit 13 NC 4 Bluetooth Receive A0 NC 5 Motor Driver ENA A1 NC 6 Motor Driver ENB A2 NC 7 Motor Driver IN1 A3 NC 8 Internal Buzzer A4 NC 9 Motor Driver IN2 A5 NC
  • 14. Control the DC Motor What is DC Motor? Any of a class of rotary electrical machines that converts direct current electrical energy into mechanical energy. There have 2 types if DC motor: 1. Brush 2. Brushless How brush DC motor works? Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 15. Control the DC Motor Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io #define BUTTON 2 #define L298N_ENA 5 #define L298N_ENB 6 #define L298N_IN1 7 #define L298N_IN2 9 #define L298N_IN3 10 #define L298N_IN4 11 void setup() { pinMode(BUTTON, INPUT_PULLUP); pinMode(L298N_ENA, OUTPUT); pinMode(L298N_ENB, OUTPUT); pinMode(L298N_IN1, OUTPUT); pinMode(L298N_IN2, OUTPUT); pinMode(L298N_IN3, OUTPUT); pinMode(L298N_IN4, OUTPUT); } Define pin 2 as internal push button. Define pin 5 as motor driver ENA. Define pin 6 as motor driver ENB. Define pin 7 as motor driver IN1. Define pin 9 as motor driver IN2. Define pin 10 as motor driver IN3. Define pin 11 as motor driver IN4. Set push button as input with internal pull up. Set motor driver ENA as output. Set motor driver ENB as output. Set motor driver IN1 as output. Set motor driver IN2 as output. Set motor driver IN3 as output. Set motor driver IN4 as output. Moving DC Motor: Write and Upload this code to your Maker UNO.
  • 16. Control the DC Motor Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void loop() { if (digitalRead(BUTTON) == LOW) { digitalWrite(L298N_ENA, HIGH); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); digitalWrite(L298N_ENB, HIGH); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } else { digitalWrite(L298N_ENA, LOW); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, LOW); digitalWrite(L298N_ENB, LOW); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, LOW); } } If button is pressed, move the motor. Enable channel A Set the direction for motor 1 Enable channel B Set the direction for motor 2 If not pressed, both motors will stop Disable channel A Disable channel B Moving DC Motor: Write and Upload this code to your Maker UNO.
  • 17. Control the DC Motor Result: When the push button is pressed, both motors will move to certain direction. So how to change the motor direction? This table shows the relationship between driver signal at channel A and motor 1 direction. Same applies to channel B and motor 2. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Motor 1 ENA IN1 IN2 Stop LOW Don’t care Don’t care Clockwise HIGH LOW HIGH Counter Clockwise HIGH HIGH LOW Brake HIGH HIGH HIGH HIGH LOW LOW
  • 18. Control the DC Motor Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io if (digitalRead(BUTTON) == LOW) { analogWrite(L298N_ENA, 200); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); analogWrite(L298N_ENB, 200); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } If button is pressed, move the motor. Set voltage at pin ENA to ~4V (200/255 x 5V) Set the direction for motor 1 Set voltage at pin ENB to ~4V (200/255 x 5V) Set the direction for motor 2 Controlling Motor Speed: You can control the motor speed by applying different voltage at enable pin by using analogWrite() function. For example:
  • 19. Set the Robot Movement Basic Mobile Robot Movement You already know how to control the motor. By combining the movement of both motors, you can set the robot movement! Below is the basic movement of the robot: 1. Stop/Brake 2. Forward 3. Reverse 4. Turn Left 5. Turn Right Note: Everyone will have a different set of program to produce the same movement. This is because we don’t have the same connection especially on motor terminal. So find yours! Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io How to move? Which direction I need to rotate so my body will move forward? ???
  • 20. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Robot Movement: FORWARD
  • 21. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Robot Movement: REVERSE
  • 22. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Robot Movement: TURN RIGHT
  • 23. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Robot Movement: TURN LEFT
  • 24. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotForward(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, HIGH); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } void robotReverse(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, HIGH); } Function for robot move forward, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to move forward Enable channel B (Left motor) Set the direction for motor 2 to move forward Function for robot go reverse, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to reverse Enable channel B (Left motor) Set the direction for motor 2 to reverse Create function: Once you have finalize your robot movement, create function for each movement - forward, reverse, turn right, turn left and stop.
  • 25. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotTurnRight(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } void robotTurnLeft(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, HIGH); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, HIGH); } Function for robot turn right, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to go reverse Enable channel B (Left motor) Set the direction for motor 2 to move forward Function for robot turn left, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to move forward Enable channel B (Left motor) Set the direction for motor 2 to reverse Create function: Once you have finalize your robot movement, create function for each movement - forward, reverse, turn right, turn left and stop.
  • 26. Set the Robot Movement Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotStop() { digitalWrite(L298N_ENA, LOW); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, LOW); digitalWrite(L298N_ENB, LOW); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, LOW); } void robotBrake() { digitalWrite(L298N_ENA, HIGH); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, HIGH); digitalWrite(L298N_ENB, HIGH); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, HIGH); } Function for robot stop Enable channel A (Right motor) Motor 1 stop Enable channel B (Left motor) Motor 2 stop Function for robot brake Enable channel A (Right motor) Motor 1 brake Enable channel B (Left motor) Motor 2 brake Create function: Once you have finalize your robot movement, create function for each movement - forward, reverse, turn right, turn left and stop.
  • 27. Serial Communication What is Serial Communication? It is a most popular communication protocol (also known as UART) used to communicate between the Arduino board and a computer or other devices. ● Bluetooth: HC-05, HC-06. ● GSM: SIM900A, SIM800L. ● WiFi module: ESP8266. ● RFid reader: 125kHz, MiFare. ● GPS, RF module, and more... Hardware Serial It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. Note: Please disconnect pin 0 and 1 during uploading sketch. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 28. Serial Communication Software Serial Due to limited number of hardware serial (only at pin 0 and 1) in Arduino Uno, SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino Uno board. However, there still have limitation on SoftwareSerial library for Arduino Uno: ● If using multiple software serial ports, only one can receive data at a time. ● Current maximum RX speed is 57600 bps. ● RX doesn't work on pin 13. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 29. Bluetooth HC-05 AT Command What is AT Command? AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at", as a prefix that informs the modem about the start of a command line. Bluetooth HC-05 AT Command Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io AT Command Description AT Check the connection. AT+VERSION Check bluetooth version. For example, it returned VERSION:3.0-20170609 AT+NAME=.... Set bluetooth name. For example AT+NAME=Maker UNO AT+PSWD="...." Set bluetooth pin number. For example AT+PSWD=”8888” AT+ORGL Restore factory setting
  • 30. Bluetooth HC-05 AT Command Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io #include <SoftwareSerial.h> SoftwareSerial HC05Serial(3, 4); void setup() { Serial.begin(9600); HC05Serial.begin(38400); } void loop() { if (Serial.available()) { HC05Serial.write(Serial.read()); } if (HC05Serial.available()) { Serial.write(HC05Serial.read()); } } Include SoftwareSerial function Set pin 3 as RX and 4 as TX Initialize Serial with 9600bps Initialize bluetooth serial with 38400bps If AT command received from Serial Monitor Send AT command to bluetooth If response received from bluetooth Display on Serial Monitor Upload this sketch to Maker UNO.
  • 31. Bluetooth HC-05 AT Command Now set your own name and pin number at your bluetooth module. For example: Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Send Received AT OK AT+VERSION VERSION:3.0-20170609 OK AT+NAME=Maker UNO OK AT+PSWD=”8888” OK
  • 32. Bluetooth HC-05 AT Command Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io To enter AT command mode in HC-05 bluetooth module, please follow these steps: 1. Turn off the bluetooth module. 2. Press and hold button on the bluetooth module. 3. Turn on the bluetooth module. 4. Release the button. Open Serial Monitor and set to 9600 baud and Both NL & CR. Next, configure bluetooth with AT command.
  • 33. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io #include <SoftwareSerial.h> SoftwareSerial HC05Serial(3, 4); void setup() { Serial.begin(9600); HC05Serial.begin(9600); } void loop() { if (Serial.available()) { HC05Serial.write(Serial.read()); } if (HC05Serial.available()) { Serial.write(HC05Serial.read()); } } Include SoftwareSerial function Set pin 3 as RX and 4 as TX Initialize Serial with 9600bps Initialize bluetooth serial with 9600bps If AT command received from Serial Monitor Send AT command to bluetooth If response received from bluetooth Display on Serial Monitor Upload this sketch to Maker UNO. Then, we can see the status of the button on the Arduino BT Joystick app at the Serial Monitor when the bluetooth is connected.
  • 34. Arduino BT Joystick Android App In this workshop, we will use Arduino BT Joystick Free. Why? Because it is free, easy to use and have a nice layout. So let’s install and open it. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 35. Arduino BT Joystick Android App FYI, Arduino BT Joystick Free is no longer available in Play Store. But don’t worry, we have prepared the APK file. You can download here (click using your phone) from Google Drive. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 36. Arduino BT Joystick Android App Finish download, click on the installer (APK) file. By default your phone setting is not allowed any installation except from Play Store. Unless you’re sure the sources, you can allow the installation on your phone setting. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 37. Arduino BT Joystick Android App Proceed with the installation. Once complete, the app icon will appear on your phone - home screen. To open it, just tap on the icon as usual. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 38. Arduino BT Joystick Android App Now we need to configure a bit on this app. 1. Click on the Menu and choose Settings. 1. Click Define the send delay. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 39. Arduino BT Joystick Android App 3. Update value in Define the send delay (ms) from 20 to 200. Click OK and Save. 3. It will return to the main screen. Now click CONNECT. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 40. Arduino BT Joystick Android App 5. Choose your bluetooth name. Make sure your bluetooth name is unique. Else, other participant will connect to your bluetooth. :) 5. Put your bluetooth pin number and click OK. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 41. Arduino BT Joystick Android App 7. If the connection successful, the CONNECT button will update to DISCONNECT. If you click on the DISCONNECT button, it will disconnect the bluetooth connection. 7. Then, if you notice, there have a set of data display on Serial Monitor (during bluetooth is connected). This is the status of the button on the Arduino BT Joystick app. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 42. Arduino BT Joystick Android App Every 200ms (set in Define the send delay), this app will send a set of data as shown in the picture above. If no key have been pressed, it sends #b=0#. Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io
  • 43. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io #include <SoftwareSerial.h> SoftwareSerial HC05Serial(3, 4); char inChar; String inString; void setup() { Serial.begin(9600); HC05Serial.begin(9600); } Include SoftwareSerial function Set pin 3 as RX and 4 as TX Global char variable for inChar Global string variable called inString Initialize Serial with 9600bps Initialize bluetooth serial with 9600bps After knowing the data set, now we need to grab the data and do comparison in the program, so that we can make specific action for specific key.
  • 44. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void loop() { if (HC05Serial.available()) { delay(100); inString = ""; while (HC05Serial.available()) { inChar = HC05Serial.read(); inString = inString + inChar; } if (inString == "#b=0#") { Serial.println("None"); } else if (inString == "#b=1#") { Serial.println("Up"); } } } If bluetooth received the data from the app Wait for 100ms so that all the data is received Clear inString variable While the data set is available Read and store to inChar variable Combined characters to form a single string Do comparison, if inString = "#b=0#" Print on Serial Monitor “None” Do comparison, if inString = "#b=1#" Print on Serial Monitor “Up”
  • 45. Arduino Bluetooth Mobile Robot Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io This is the final stage to create Arduino Bluetooth Mobile Robot. Make sure the previous chapters is working. 1. Set the robot movement together with functions. 2. Configure bluetooth using AT command (name, pin #). 3. Read data set from the app. 4. Compare and do specific action. 5. Now, combine no 1 and 4.
  • 46. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io #define RX 3 #define TX 4 #include <SoftwareSerial.h> SoftwareSerial HC05Serial(RX, TX); #define BUTTON 2 #define L298N_ENA 5 #define L298N_ENB 6 #define L298N_IN1 7 #define L298N_IN2 9 #define L298N_IN3 10 #define L298N_IN4 11 char inChar; String inString; Define pin 3 as received pin = HC05 TX. Define pin 4 as transmit pin = HC05 RX. Include SoftwareSerial function Set pin 3 as RX and 4 as TX Define pin 2 as internal push button. Define pin 5 as motor driver ENA. Define pin 6 as motor driver ENB. Define pin 7 as motor driver IN1. Define pin 9 as motor driver IN2. Define pin 10 as motor driver IN3. Define pin 11 as motor driver IN4. Global char variable for inChar Global string variable called inString
  • 47. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void setup() { Serial.begin(9600); HC05Serial.begin(9600); pinMode(BUTTON, INPUT_PULLUP); pinMode(L298N_ENA, OUTPUT); pinMode(L298N_ENB, OUTPUT); pinMode(L298N_IN1, OUTPUT); pinMode(L298N_IN2, OUTPUT); pinMode(L298N_IN3, OUTPUT); pinMode(L298N_IN4, OUTPUT); } Initialize Serial with 9600bps Initialize bluetooth serial with 9600bps Set push button as input with internal pull up. Set motor driver ENA as output. Set motor driver ENB as output. Set motor driver IN1 as output. Set motor driver IN2 as output. Set motor driver IN3 as output. Set motor driver IN4 as output.
  • 48. BT JoysArduino tick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void loop() { if (HC05Serial.available()) { delay(100); inString = ""; while (HC05Serial.available()) { inChar = HC05Serial.read(); inString = inString + inChar; } if (inString == "#b=0#") { robotStop(); } else if (inString == "#b=1#") { robotForward(200); } else if (inString == "#b=2#") { robotReverse(200); } else if (inString == "#b=3#") { robotTurnLeft(150); } else if (inString == "#b=4#") { robotTurnRight(150); } } } If bluetooth received the data from the app Wait for 100ms so that all the data is received Clear inString variable While the data set is available Read and store to inChar variable Combined characters to form a single string If inString = "#b=0#" Robot stop If inString = "#b=1#" Robot move forward with PWM 200 If inString = "#b=2#" Robot go reverse with PWM 200 If inString = "#b=3#" Robot turn left with PWM 150 If inString = "#b=4#" Robot turn right with PWM 150
  • 49. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotForward(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, HIGH); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } void robotReverse(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, HIGH); } Function for robot move forward, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to move forward Enable channel B (Left motor) Set the direction for motor 2 to move forward Function for robot go reverse, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to reverse Enable channel B (Left motor) Set the direction for motor 2 to reverse
  • 50. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotTurnRight(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, LOW); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, LOW); } void robotTurnLeft(int robotSpeed) { analogWrite(L298N_ENA, robotSpeed); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, HIGH); analogWrite(L298N_ENB, robotSpeed); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, HIGH); } Function for robot turn right, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to go reverse Enable channel B (Left motor) Set the direction for motor 2 to move forward Function for robot turn left, speed = 0 - 255 Enable channel A (Right motor) Set the direction for motor 1 to move forward Enable channel B (Left motor) Set the direction for motor 2 to reverse
  • 51. Arduino BT Joystick Android App Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io void robotStop() { digitalWrite(L298N_ENA, LOW); digitalWrite(L298N_IN1, LOW); digitalWrite(L298N_IN2, LOW); digitalWrite(L298N_ENB, LOW); digitalWrite(L298N_IN3, LOW); digitalWrite(L298N_IN4, LOW); } void robotBrake() { digitalWrite(L298N_ENA, HIGH); digitalWrite(L298N_IN1, HIGH); digitalWrite(L298N_IN2, HIGH); digitalWrite(L298N_ENB, HIGH); digitalWrite(L298N_IN3, HIGH); digitalWrite(L298N_IN4, HIGH); } Function for robot stop Enable channel A (Right motor) Motor 1 stop Enable channel B (Left motor) Motor 2 stop Function for robot brake Enable channel A (Right motor) Motor 1 brake Enable channel B (Left motor) Motor 2 brake
  • 52. End of Workshop Arduino Bluetooth Mobile Robot by Cytron Technologies - https://www.cytron.io Thank you and Let’s Play! Q & A Session