... For Dummy: "Controlling Your Arduino Mobile Robot Using Android Bluetooth App"
... For Dummy: "Controlling Your Arduino Mobile Robot Using Android Bluetooth App"
Version 2.0
Cytron Technologies Sdn Bhd - https://www.cytron.io
Arduino Bluetooth Mobile Robot Module Content
No TOPIC DURATION
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.
● Autonomous
○ Robot moves automatically based on the sensors and other gear.
● Manual
○ Robot moves depend on the command received from the instructor.
1. Robot chassis.
2. Motor, motor driver and wheels.
3. Controller.
4. Battery.
Quantity Description
4 PCB Stand
1 sets 4 x AA Battery
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.
What is ?
Serial Pin
Arduino ISP Pin Hardware Serial (UART) is
This pin can be used for SPI and labeled with RX and TX pin.
bootloader programming.
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
Menu Bar
Button Bar Serial Monitor
Sketch Name
Code Area
Status Bar
IDE Output
Board Name and Port
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.
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
3 Bluetooth Transmit 13 NC
4 Bluetooth Receive A0 NC
8 Internal Buzzer A4 NC
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
digitalWrite(L298N_ENB, HIGH);
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, LOW); Enable channel B
} Set the direction for motor 2
else {
digitalWrite(L298N_ENA, LOW);
digitalWrite(L298N_IN1, LOW);
digitalWrite(L298N_IN2, LOW); If not pressed, both motors will stop
Disable channel A
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW);
digitalWrite(L298N_IN4, LOW);
}
} Disable channel B
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.
For example:
if (digitalRead(BUTTON) == LOW) { If button is pressed, move the motor.
analogWrite(L298N_ENA, 200); Set voltage at pin ENA to ~4V (200/255 x 5V)
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, LOW); Set the direction for motor 1
analogWrite(L298N_ENB, 200);
digitalWrite(L298N_IN3, HIGH); Set voltage at pin ENB to ~4V (200/255 x 5V)
digitalWrite(L298N_IN4, LOW); Set the direction for motor 2
}
You already know how to control the motor. By combining the movement of both
motors, you can set the robot movement!
How to
Below is the basic movement of the robot: move? ???
1. Stop/Brake
2. Forward
3. Reverse
4. Turn Left Which direction I need
to rotate so my body
5. Turn Right will move forward?
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!
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Set the direction for motor 2 to move forward
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Set the direction for motor 2 to move forward
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Motor 2 stop
void robotBrake()
{
digitalWrite(L298N_ENA, HIGH); Function for robot brake
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, HIGH);
Enable channel A (Right motor)
digitalWrite(L298N_ENB, HIGH); Motor 1 brake
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, HIGH);
}
Enable channel B (Left motor)
Motor 2 brake
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.
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.
AT Command Description
Send Received
AT OK
VERSION:3.0-20170609
AT+VERSION
OK
AT+NAME=Maker UNO OK
AT+PSWD=”8888” OK
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.
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.
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.
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.
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#.
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Set the direction for motor 2 to move forward
analogWrite(L298N_ENB, robotSpeed);
digitalWrite(L298N_IN3, HIGH); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Set the direction for motor 2 to move forward
digitalWrite(L298N_ENB, LOW);
digitalWrite(L298N_IN3, LOW); Enable channel B (Left motor)
digitalWrite(L298N_IN4, LOW);
} Motor 2 stop
void robotBrake()
{
digitalWrite(L298N_ENA, HIGH); Function for robot brake
digitalWrite(L298N_IN1, HIGH);
digitalWrite(L298N_IN2, HIGH);
Enable channel A (Right motor)
digitalWrite(L298N_ENB, HIGH); Motor 1 brake
digitalWrite(L298N_IN3, HIGH);
digitalWrite(L298N_IN4, HIGH);
}
Enable channel B (Left motor)
Motor 2 brake