Simple Arduino Bluetooth Cybot on the Move and Android Appplication (updated)

by HUKBMBEAR in Circuits > Arduino

3211 Views, 30 Favorites, 0 Comments

Simple Arduino Bluetooth Cybot on the Move and Android Appplication (updated)

H.jpg
title pic.jpg
APP2.jpg

A while back I wrote a couple of instructables for user interface creation and the control of the Cybot base using commands from either the keyboard or from a bar code scanner.

Links to these are below:

User interface:https://www.instructables.com/id/Direction-display-...

Barcode Control: https://www.instructables.com/id/Scratch-4-Arduino-...

Both employed the Scratch 4 Arduino language for the software control side. At the end of these I mentioned that I wanted to carry on to use Bluetooth to control the base, this guide covers that wish.

I will be entering this into a couple of competitions

If you like this and possibly find it helpful please vote for it.

Thanks

The first thing I will say for anyone wanting to try Bluetooth control is that there are a lot of sites on the web advocating the use of the RX/TX connections and even have videos of it in operation, what they dont say is how long it took them to get it to work or how many issues they had in doing so. That is why I eventually tried the Serial library and defined two of the arduino pins as the serial communication lines.

For this instructable - (if you intend to repeat) you will need to install the appropriate application for your computer from the arduino site http://arduino.cc/en/Main/Software

I used an Arduino Nano v3.0 and an additional board which gave me screw connections for easy wiring. the bluetooth module is from LC Technology, all of these I purchased from Ebay and where incredibly cheap I think the all together it came to £11.00.

You will also need the Cybot base - you can use others, but I chose this mainly because I already had it, but also because it already had a H bridge board for the control of the two attached motors.

INSTRUCTABLE Updates

I have made a couple of changes / additions to the guide as follows

  1. Safety related - see the wiring section - the motor board was getting hot so have rewired to remove the issue and explained in in that section
  2. Created a basic navigation application and added a section to cover this

Software

bt1.jpg
btterminal.jpg

Bluetooth

Whichever bluetooth dongle you have it will need to be installed on you computer - this is a simple matter of following its manufacturers instructions and installation disk.(this I did for my main computer, but on my notebook i let it select the appropriate windows drivers)

Note that you will probably have to restart your computer for it to work as designed.

Terminal Application

The terminal application used to test the operation is called CoolTerm and is a free application available from http://freeware.the-meiers.org/

Once installed - open it and select the options button then scan for serial communications - note - your bluetooth needs to be powered up for it to be located.

When you are ready to try out you creation - select Connect from the main window.

Tip turn you bluetooth power on then any other power to the motors (only say this as mine has a separate battery pack) then do the serial search and finally connect - it might take a couple of attempts so be patient. once the led on the bluetooth has stopped flashing you are connected. if it does not work check for loose connections.

Making a Harness for the Cybot Connections

10.jpg
09.jpg
08.jpg
01.jpg
02.jpg
03.jpg
13.jpg
12.jpg
14.jpg
15.jpg
16.jpg
17.jpg

The cybot motors are controlled via an H-Bridge board which was desined to link up with other boards in the robot, but to keep interest in the build the publishers of the magazine supplied a jumper board which linked the power to the forward motion pins for both motors and let the base drive forwards.

I too this and removed the track between these pins. The I stripped and tinned 7 wires (each a different color for easy identification) and soldered a single wird to each of the seven pins

I later found that I had managed to link some of these pins so shorting connections an preventing proper operation (I will go back and fix this later)

As part of the harness I also used heat shrink in an attempt to stop potential shorting (that really worked didnt it)

Bluetooth Cable

23.jpg
06.jpg
bt1.jpg
bt2.jpg
04.jpg
21.jpg
22.jpg

Before I stated connecting up the components to the cybot I used a breadboard to test out the various parts trying to reduce wasted time later. once this was done I had to make up a Dupont cable conection (see pictures) as I only had four and two pin connectors I made up one of each and later used a drop of hot glue to hold them together.

The only pins needed for this project are the Ground/RX/TX and 5 volt, but I connected a cable for each for future use if needed.

Cable Connections

18.jpg
07.jpg
19.jpg
wire6.jpg
bt connected.jpg
bt connected 2.jpg

The manufacturers of the Cybot motor board numbered the connections 1 to 7 starting on the right with 1and you need to remember this when wiring up.

So there are 7 connections (the black block to the top of the first picture close to the green LED)

PinDescription of function
1Right Motor - Forward
2Right Motor - Reverse
3Left Motor - Forward
4Left Motor - Reverse
5+ 5 volt Output
6+ 6 volt Output
7Zero Volts

I have at present only connected up to the motor pins and the 0 volt pin so that's pins 1,2,3,4 and 7 of the cybot board.

If you take a look at the Arduino Sketch you can see that I have named the variables for the direction pins as per the table below the connections to the board are also shown in the table below, (8,9,12 and 13 - connect one to each of the Cybot pins the last pin connected is the ARef pin of the Arduino to +6 volt pin of the motor board.)

Table of pin connections motors to Arduino

Cybot Pin Arduino Pin
1 - RM ForwardTo~8
2 - RM ReverseTo~9
3 - LM ForwardTo~12
4 - LM ReverseTo~13
7 - 0 volt OutputToGround


BIG NOTE -- I originally connected the 6 volt (pin 6) of the cybot motor board to the reference pin of the Arduino. This resulted in a couple of observations.

1. One of the wheels received a continuous supply which made it turn slowly, but not enough to see until you picked the base up.

2. The motor board started to get hot -- this was due to a continuous short through board from the additional power coming from the arduino on top of that supplied by the dedicated motor supply.

By changing the wires in this way the wheel stopped spinning and the heating up stopped. RESULT


Bluetooth Connections to the Arduino

Bluetooth pin Arduino Pin
GroundToGround
5 voltTo~5V
RX To~11
TXTo~10

Power is supplied to the H-Bridge via the Cybot powerpack on the under side of the base, while the Bluetooth Circuit is powered by a separate battery pack with connections to Ground and the Vin pins of the Arduino

If your going to recreate this I can recommend getting the Screw lock for the Arduino see picture 2 as it makes connections very easy.

Attaching the Additional Battery PAck

battery 1.jpg
battery 2.jpg
glue 1.jpg
glue 2.jpg
glue 3.jpg

As mentioned I used an additional pack to power the bluetooth : Arduino circuit this was attached to the top of the built in bas battery pack for the motors using hot melt glue. I also placed a spot of glue on the dupont connectors on the Bluetooth module to hold them tegether.

Arduino Firmware

Before you try to upload the sketch for the Arduino ensure that you port is selected from the tools drop down in the Arduino IDE, but mre importantly select the correct board you are using.

The code below will work on most if not all Arduino boards, but if you have the wrong type set under tools then you will only get errors when you click the upload button.

I had a number of issues when I first ran this, not connecting, motors not running or running inconsistently.

To trouble shoot issues I suggest removing the Arduino and Bluetooth from the Cybot and set up on a breadboard and get each step working before moving on.

Working as above I found that the cable harness I had made to link the Cybot H bridge to the Arduino was shorting out which resulted in temperamental operation.

So while I think its a good idea to use the harness and have left its creation in as part of the instructable - you will notice that the fully operational video has direct connections using jumper wires

// Firmware for the Arduino Nano for Bluetooth control of the Cybot platform

// this file does not use the TX/RX connections on the arduino for serial communication so make the following conncetions

// arduino>>bluetooth // D03 >>> Rx

// D02 >>> Tx

#include // this is a must or the serial communication will not work

SoftwareSerial Cybot(10,11); // RX, TX setup

int RM_forward=8; // setup referenced pin for on / off activity

int RM_reverse=9; // setup referenced pin for on / off activity

int LM_forward=12; // setup referenced pin for on / off activity

int LM_reverse=13; // setup referenced pin for on / off activity

int BluetoothData; // the data given from Computer

void setup() { // initial status setup

Cybot.begin(9600);

Cybot.println("Bluetooth On press 8:forward / 2:reverse / 4:left / 6:right / 0:stop");

pinMode(RM_forward,OUTPUT);

pinMode(RM_reverse,OUTPUT); pinMode(LM_forward,OUTPUT);

pinMode(LM_reverse,OUTPUT);

}

void loop() { // put your main code here, to run repeatedly:

if (Cybot.available()){ BluetoothData=Cybot.read();

// Forward

if(BluetoothData=='1'){ // if number 1 pressed .... first stop all activity then turn on the forward motion

digitalWrite(RM_forward,0);

digitalWrite(LM_forward,0);

digitalWrite(RM_reverse,0);

digitalWrite(LM_reverse,0);

digitalWrite(RM_forward,1);

digitalWrite(LM_forward,1);

Cybot.println("Forward");

}

// Backward

if(BluetoothData=='2'){ // if number 2 pressed .... first stop all activity then turn on the backward motion

digitalWrite(RM_forward,0);

digitalWrite(LM_forward,0);

digitalWrite(RM_reverse,0);

digitalWrite(LM_reverse,0);

digitalWrite(RM_reverse,1);

digitalWrite(LM_reverse,1);

Cybot.println("Backwards");

}

// Right

if(BluetoothData=='4'){ // if number 4 pressed .... first stop all activity then turn on the right motion digitalWrite(RM_forward,0);

digitalWrite(LM_forward,0);

digitalWrite(RM_reverse,0);

digitalWrite(LM_reverse,0);

digitalWrite(RM_reverse,1);

digitalWrite(LM_forward,1);

Cybot.println("Right"); }

// left

if(BluetoothData=='6'){ // if number 6 pressed .... first stop all activity then turn on the left motion digitalWrite(RM_forward,0);

digitalWrite(LM_forward,0);

digitalWrite(RM_reverse,0);

digitalWrite(LM_reverse,0);

digitalWrite(LM_reverse,1);

digitalWrite(RM_forward,1);

Cybot.println("Left");

}

// STOP

if(BluetoothData=='0'){ // if number 0 pressed .... stop all activity

digitalWrite(RM_forward,0);

digitalWrite(LM_forward,0);

digitalWrite(RM_reverse,0);

digitalWrite(LM_reverse,0);

Cybot.println("STOP");

}

}

delay(100);// wait for input

}

Downloads

Tidy Up the Wires

C.jpg
D.jpg
E.jpg
F.jpg
B.jpg
G.jpg
title pic.jpg
I.jpg

Once it was all working it as time to tidy up the wires,

To do this I simply re-routed some of the cables and attached the Bluetooth switch to the under side using hot glue.

I also needed to make a mount for the Bluetooth module - for this I use 4 Dupont connector cases and hot glued then together the attached the Bluetooth cable and the mount to the base using hot glue.see pictures

Android App - Botnav1

APP1.jpg
APP2.jpg
APP3.jpg
APP4.jpg
APP5.jpg
APP6.jpg
APPICON.jpg

I was having a play with App Inventor last night and created my first functional APP that wasnt one of the tutorials.

This section has the pictures that describes its function and once I get a chance I will include a video of it in operation.

I called the app Botnav1 its very basic so please be kind if you make comments - as the layout needs a bit of attention. The functions included are

  • Select Bluetooth (device)
  • Connect (this changes to Disconnect if already linked to a device)
  • Direction controls (forward/Backward/Left and Right)
  • Off (turns all motors off)

the second picture shows the screen layout with the remaining 4 depicting the programming blocks.

  1. Block picture 1 - identify the bluetooth modules available
  2. Block picture 2 - operation of the connect button to attach / detach to a bluetooth module
  3. Block picture 3 - Basic direction control including stop
  4. Block picture 4 - naming of the application elements on the design screen

For the application icon I used the navigation arrows from my previous instructable on interface design

The APK file is attached to this guide have fun

Downloads

Next Steps

The next update for this will be to improve the Android Application.

I think it might also be kind of fun to include GPS and then map the house so that I can see if I can write the code to navigate the map without actually having to see the robot.

I will be entering this into a couple of competitions if you like this and possibly find it helpful please vote for it.

Thanks