You are on page 1of 14

Arduino Coding and

Bluetooth Connection
A STEP BY STEP GUIDE
Bluetooth application
● In order to make the arduino robot be able to connect to your phone, a blue
connection needs to be established.
● Using the Bluetooth HC05, we can connect to the arduino robot
Elements of the Bluetooth HC05
● VCC is used for voltage, and has a higher VCC power input and a positive
voltage supply
● The VCC is usually a voltage of 5V
● GND is the ground and represents a low level of input voltage
● TxD is used to transmit data
● RxD is used to receive data
Establishing the connection
● To allow for the connection to happen, We must connect the ‘TXD’ wire of the
bluetooth module to the ‘RXD’ port on the arduino board.
● Afterwards, we also have to connect the ‘RXD’ to the ‘TXD’ wire
● We connect the VCC to the 5V of arduino and the GND to the GND of arduino
Void functions
● In order to start coding, we must download the Arduino software. When
Arduino is downloaded, void setup() is seen.
● void setup is a function on top of each program and allows for the code to run
one time when the program starts running
● Void loop() is used to create loop functions which continuously repeats
Creating global variables
● Using int variables, we create global variables for the motor pin numbers
(connected to the arduino board) and reference them within our code
● For example, if the motor pins connected to the arduino board were 8,9,10,11,
the following code would be:
pinMode()
● Afterwards, we create the pinMode() functions which is a function that allows
for certain pins to act as INPUT or OUTPUT. It requires 2 inputs.
● OUTPUT is used when the arduino board is connected to the computer and
receives incoming data.
● For example, a code would be:
Serial Communication
● Serial communication, which allows for devices to communicate to one another (such as your laptop and the arduino
board) by doing:

● Serial.begin establishes a communication between the Arduino board and another device. In this case, the value
inside the brackets, such as 9600 is the band rate and how fast the data is to be sent.
● Afterwards, a while loop is created in order to only send data when data received is over 0 bytes. In order to do this,
we make the serial available over 0:
MOVING THE ARDUINO ROBOT

● In order to make the Arduino Robot move around, we have to label the
following control movements with values the remote recognises. For example:
● ‘F’ - Forward
● ‘B’- Backwards
● ‘R’- Right
● ‘L’- Left
● ‘S’- Stop
Making the Arduino Car Move Forward
● The use of the function digitalWrite(), is used to allow us to assign the pin
receiving or not receiving volts.
● For example, if we want to make the car move forward, we assign the two
pins that cause the car to move forward as ‘HIGH’. This is shown below:
Making the Arduino Car Move Backwards
● In order to make the Arduino Car move backwards, we have to do make the
pins that cause the robot to move backwards set to ‘HIGH’ and the robot pins
that make it move forward set to ‘LOW’. This is shown in the example below:
Making Arduino Car move Left
● In order to make Arduino move Left, we only have one pin, which is the left
forward pin receiving volts. This is shown in the example below:
Making Arduino Car move Right
● The same applies for this one. In order to make the Arduino Car move right,
we have the forward right port receiving volts.
Connection to mobile devices
● Using the iOS application ‘BLEJoyStick, the arduino car can be connected via
bluetooth. When going on the application, the pairing password would be
‘1234’, and with this, the robot is able to move around through the use of a
remote control
● Other Android related remote controls can be used as well

You might also like