Monday, February 29, 2016

Arduino Bluetooth Controller

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.


    For detailed explanation of the Schemaic Representation please see here

  • Below is the full example code.



6 comments:

  1. Thanks for sharing. This is great. I'm fairly new to the arduino world so i've been having some difficulty programming the ultrasonic to work while implementing a remote control feature. This worked like a charm. Thanks again!

    ReplyDelete
  2. Thanks for sharing. This is great. I'm fairly new to the arduino world so i've been having some difficulty programming the ultrasonic to work while implementing a remote control feature. This worked like a charm. Thanks again!

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I did not get your question. Can you come again?

      Delete
    2. not sure if this would help but here is the link with the detailed schematics
      https://robust-tech.blogspot.com/2016/03/arduino-bluetooth-controller-detailed.html

      Delete