PRE-REQUISITE
The app is a reference document for users who have built Arduino enabled car and need the android app to control it over a Bluetooth module. (Eg. HC-06).
In the below example I have configured Arduino Uno with the Ultrasonic Sensor, Bluetooth Module HC-06 and L293D which is basically a collision avoidance car. If you need more information about the schematic let me know in the comments section.
Referenced App: Arduino Bluetooth Controller
SET-UP
- Please make sure you configure and pair your Bluetooth module on your android phone under settings.
- The buttons on the app are preconfigured to send specific codes which you have to configure on your Arduino.
- The Pin setup code is as below
Function
|
Code
|
Forward
|
1
|
Back
|
2
|
Right
|
3
|
Left
|
4
|
Stop
|
5
|
Auto Pilot
|
8
|
Fn1
|
6
|
Fn2
|
7
|
Fn3
|
9
|
- Please find below the code snippet. The code sent from the app can be read by arduino as below. In the below snippet if the received character is 1 then it will process the code block for user defined function "forward()" which sends the instructions to run both the motors in forward direction.
receivedChar = mySerial.read(); if (receivedChar == '1') { forward(); flag = 6; }
- Few things to note here,
- The autopilot function is very basic, you can add a servo and rotate it 180 degrees to determine the best possible path instead of a random path.
- i have provided 3 buttons which do not have any implementation in the sample code ( fn1 till 3) but they are empty slots provided in the app. You can use it in case you want to perform some additional magic with the robot.
- Below is the full example code.
For detailed explanation of the Schemaic Representation please see here