Thursday, March 10, 2016

Arduino Bluetooth Controller - Detailed Schematic Representation

Components Used:


  • Arduino Uno
  • Breadboard and bunch of jumper cables
  • HC-06 (I bought a JY-MCU from ebay)
  • L293D (I bought a Motor Shield which has 2 of these ICs for cheap from ebay)
  • Chasis (includes the motors) 
  • 6V rechargeable battery – I connected a separate set to power the motors.


Connecting various components with Arduino.  

Below is the schematic representation of the Bluetooth Controlled Car.


Resistor on Row E - 100 ohm
Resistor on Row D - 220 ohm


Pin Configuration


Pins
Connections
2
Trigger – Ultrasonic Sensor
3
L293D – Motor : Right Back
4
Echo – Ultrasonic Sensor
5
L293D – Motor : Right Forward
6
L293D – Motor : Left Back
7
TX à to RX of Bluetooth Module
8
RX à to TX of Bluetooth Module
11
L293D – Motor : Left Forward

Connecting the Bluetooth module:

P.S. Now I have heard of various people complaining about frying their chips when a (TX) transmitting signal of 5v is sent across to RX of Bluetooth module so why risk it, below are the steps to starve the TX input of Bluetooth module.
For cutting down the input from 5v to 3.3 volt. You can configure the resistors as below. I have used 100 ohm and 220ohm resistors, the 220 ohm resistor is connected between GND and RX of BT module and 100 between TX of Arduino and RX of BT module as below.









Note: Now did you notice about the TX RX confusion? TX of Arduino will be connected to RX of Bluetooth module and RX to TX. Think about it for sometime and you will get it – The Bluetooth will be receiving the data only when arduino actually transmits it. So for Arduino it is a TX signal while the same is RX for Bluetooth Module. 







Configuring the L293D

Why L293D? – remember we need a car that roams around freely not just forward. For this we have to use the same motor to move clockwise or anticlockwise and one clockwise and another anticlockwise when turning and vice-versa when turning the other way.

So this chip is actually an H-Bridge which does the magic of flipping the flow of current to the motors so that it moves in the said direction. If you want to skip the details and just need the schematic diagram then here you go.




If you need to go for a deepdive then follow this


Configuring Ultrasonic Sensor

 This is pretty simple and straight forward. Just follow the diagram and you are good to go.







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.