I’ve bought me a HC05 bluetooth module on Ebay. And I also recently got me a Samsung smartphone. When you trow an Arduino robot in the mix you get the above video 🙂
The HC05 bluetooth modules seem to be very popular. You can easily find them on Ebay. I bought the module on a small PCB that has a 3.3V voltage regulator. As the HC05 module works at 3.3V. Communicating with the module is very easy. It’s just plain simple serial, so you don’t need any special libraries.
I connected the TX/RX signals of the HC05 bluetooth module to an ATmega1284 through a voltage divider. I used a 10K and a 5K6 resistor to drop the voltage from 5V to 3.2V. I just soldered the resistors and some pins to a piece of perfboard. I used an ATmega1284 as it has 2 serial ports, one for uploading sketches and the serial monitor and the other for the bluetooth module. You can of course connect it to an Arduino with an ATmega328 using the software serial library. It doesn’t make much difference in the code.
So after connecting the HC05 module to my Bajduino I needed to try it out. I just got myself a new Android smartphone so I started browsing the Android play store for a suitable app. Then I remembered that Rocket Brand Studios sells a small app to control a robot, Rocketbot robot controller. It isn’t a free app but it costs less then 2€. And I have to say it is a great app for a small price.
After successfully trying out the example sketch from Rocket Brand studios I wrote a simple sketch to control a robot with 2 continuous rotation servos. Here is the sketch:
// Bluetooth controlled Arduino robot // http://www.bajdi.com // HC05 bluetooth module receicing 2 bytes from Android app // Android app = Rocket Bot Controller (rocketbrandstudios.com) // 2 continuous rotation servos // µController = ATmega1284P-PU #include <Servo.h> Servo leftServo; // create servo object to control a servo Servo rightServo; // create servo object to control a servo int qualifier; int dataByte; void setup() { Serial.begin(57600); // serial monitor Serial1.begin(9600); // HC05 bluetooth module leftServo.attach(21); leftServo.write(90); // stop servo rightServo.attach(22); rightServo.write(90); // stop servo } void loop() { if(Serial1.available()>1) { qualifier=Serial1.read(); dataByte=Serial1.read(); Serial.print("qualifier = "); Serial.println(qualifier); Serial.print("dataByte = "); Serial.println(dataByte); if ( qualifier == 68) { if (dataByte == 1) { forward(); } if (dataByte == 2) { left(); } if (dataByte == 3) { right(); } if (dataByte == 4) { backward(); } if (dataByte == 5) { stop(); } } } } void stop(){ leftServo.write(90); // stop rightServo.write(90); // stop } void forward(){ leftServo.write(0); // go straight forward rightServo.write(120); } void backward(){ leftServo.write(180); // backward rightServo.write(60); } void left(){ leftServo.write(140); // go left rightServo.write(100); } void right(){ leftServo.write(40); // go right rightServo.write(80); }
Howdy,
So I was in the process of designing a simple robot with similar functionality to yours. It only utilizes 2 servo motors and is controlled by a B-328 Baby Orangutan (it’s a ATmega328P AVR microcontroller). I was curious on whether I really needed an HC-05 or if I could just use the HC-06 (slave only bluetooth module) and whether or not I should purchase one on an XBee module or not. I’m using an external programmer for it, but it can be boot loaded with Arduino if necessary. Do you have any pointers for me?
V/r,
Jacob McIntosh
HC05 or 06 should both work fine for your purpose. No need to buy one on an Xbee module.
And the 68 prefix works because its something hardcoded into the droid app used to tag bt signals coming form the buttons in the app?
Yes, that’s correct. If you want to change that you would need to write your own Android app.