Introduction: Mobile Phone Controlled Robot

This Robot is great for a class project as it is cheap an easy to make. You can add to it and program it to do all sorts of things, and in this Instructable Ill show you how to drive it from your phone using Bluetooth.

Step 1: Stuff You Will Need

To keep the cost down you can get most of the parts from ebay or aliexpress. Here is a list of the stuff you will need.

You will also need to cut out the frame parts from 3mm acrylic on a laser cutter

Step 2: While Your Waiting for the Parts to Arrive.

Before you start your robot project it is a good idea to get familiar with the software we are going to use. To control the robot you will need to build an app for your phone. Mit app inventor is great for this and has lots of videos and tutorials to get you started. You will need an android phone, and a computer on the same network, and Its free to make an account.

Near the top center right of the screen you will see the guide icon and this will take you to lots of videos and tutorials click on the beginner videos. They will show you how to get started.

Challenges, can you?

  • Make your phone talk when you push a button
  • Make your phone talk when you shake it
  • Make a ball bounce on the screen?
  • Make your screen into a doodle pad?
  • Bored yet? check out 100 appinventer videos

Step 3: Still Waiting?

You will need to get familiar with Arduino, download the software and the driver if you are using a arduino clone. Some mac books will shut down if you don't have the driver installed. Here are the links Arduino IDE and the Mac Driver for Arduino clones.

Once you have everything on your computer, you can start to play.

There is so much information on the net about arduinos you might get overwhelmed, so here is a good place to start. Core electronics has some great video and tutorials. Near the bottom of the screen it has an arduino blink tutorial which is a good place to start.

Challenges, can you?

  • Make an LED blink at different speeds?
  • Get 2 LEDs to Blink?
  • Get 2 LEDs to Blink at the same time?

  • Get 2 LEDs to Blink alternately using only 2 delays?

  • Make a LED chaser with lots of LEDs?
  • Make the brightness of an LED fade ?
  • Make a set of traffic lights, with a pedestrian switch?

When you get sick of playing with LEDs have a look PDF at the bottom of the page and check out the other tutorials on the core website.


Step 4: Assembling Your Robot

All the steps have lots of photos with notes, so click on a photo and use the arrow keys to get to the next instruction.

Now you have your parts you can start assembling them. The laser cut frame has to be up the right way or the arduino wont fit, so check that before you start. The files for the frame and wheels are at the bottom of the page.

  • Fit the screws to the ardunio with nut on the bottom side to provide clearance between the underside of the PCB and the frame.
  • One of the screw holes on arduino is very close to the pin headers, making it diffcult to fit. You can leave it off and mount with 3 screws.
  • The ardunio can then be attached to the frame.
  • The motor driver can be attached the same way as the ardunio was.
  • The four stand offs can then be attached.
  • If your motors need the wires soldered on you will need to attach them before you put the motors into the frame.
  • This would also be a good time to attach the wheels.
  • The battery pack fits between the two motors
  • The motors can be attached with double sided tape.
  • The top and bottom frames can be attached with 3mm screws.

Step 5: Making the Wheels

The wheel can also be cut out on the laser cutter, and are simple to assemble. They are quite a tight fit n the motor shaft, so take care when fitting them.

You can use 3mm screws and nuts, to assemble them or glue, but they will have to have the hole in the center carefully aligned on the shaft if you choose to use glue.

the o ring can be fitted and the center 2mm screw fastened to the motor and your done your done

Step 6: Wiring Up the Robot

Wiring up is quite simple, first each motor has two wire each, which go into the terminal blocks on each side.

Next have a look on the front of the motor motor driver you will see four pins labeled "in1" "in2" "in3" "in4"

Plug four of the male to female jumper cables in

to them.

The male ends go into the arduino on pins 9,10,11, and 12

  • in1 to pin 9
  • in2 to pin 10
  • in3 to pin 11
  • in4 to pin 12

Next cut the female end off a red jumper cable and connect it to the positive wire on the battery, then connect both to the positive side of the motor driver, and the male end to the "Vin" on the arduino

Cut the female end off a black jumper and connect it to the negative side of the terminal block, the male end can be connected to the GND pin on the arduino

Cut another jumper cable and solder it to the negative battery wire, use some heat shrink to insulate the join. when this cable is plug into another GND pin on the arduino the robot should light up.

You can use 2 two cell battery holders instead of a 4 cell holder just join the red an black wires together as shown

Step 7: Coding the Arduino

Coding the arduino can be a bit of a challenge if you have not done it before, but Ill go through the code at show you what it does . We are not going to use the phone to drive it at this stage.

Make sure you check the correct com port and upload the code to the arduino.

You can then check if everything works by using the serial monitor on the ardino IDE. Sent the letters f, b,s,l,r,t and see what happens. This will allow you to drive the robot while connected to the computer via a USB cable.

If you look at the code everything after the two forward slashes // is a description of what that line does, from there you can get an idea of what each part does.

Challenges, can you?

  • add to the code to make the robot spin the other way
  • make the robot move forward for 2 seconds then stop
  • Add head light, turn signals, a horn
  • add "dance mode" to the code
char getstr; // tells Arduino to look for a text signal<br>int in1=9;  // renames the pins to make it easy to program 
int in2=10; 
int in3=11; 
int in4=12; 
// tells you where to connect the wire on the arduino and motor driver
 
void _mRight(int pin1,int pin2)// set up pins to turn motors on or off
{ 
 
 digitalWrite(pin1,HIGH); 
 digitalWrite(pin2,LOW); 
} 
void _mLeft(int pin1,int pin2)// motor left command will turn pin 1 low and pin 2 high 
{ 
 digitalWrite(pin1,LOW); 
 digitalWrite(pin2,HIGH); 
} 
void _mStop(int pin1,int pin2)// Motor stop command will turn pin 1 and 2 high
{ 
 digitalWrite(pin1,HIGH); 
 digitalWrite(pin2,HIGH); 
} 
void setup() 
{ 
 Serial.begin(9600); // sets up rate for data transmission
 pinMode(in1,OUTPUT); // renamed pins (as above) are set as outputs 1,2 are left motor
 pinMode(in2,OUTPUT); 
 pinMode(in3,OUTPUT); // 3,4 are right motor
 pinMode(in4,OUTPUT); 
 
 
 digitalWrite(in1,HIGH); // if no text signal all output are high so robot wont move
 digitalWrite(in2,HIGH); 
 digitalWrite(in3,HIGH); 
 digitalWrite(in4,HIGH); 
} 
void loop() 
 
{ 
 getstr=Serial.read(); 
 if(getstr=='f') // if an "f" text is read 
 { 
 Serial.println("go forward!"); // arduino will sent text back "go forward"
 _mStop(in1,in2);  // turn off left motor
 _mStop(in3,in4);  // turn off right motor
 _mRight(in1,in2); // left motor forward
 _mRight(in3,in4); // right motor forward
 } 
 else if(getstr=='b') // if a "b" text is read 
 { 
 Serial.println("go back!"); // arduino will sent text back "go back"
 _mStop(in1,in2); // turn off left motor
 _mStop(in3,in4); // turn off right motor
 _mLeft(in1,in2); // left motor backwards
 _mLeft(in3,in4); // right motor backwards
 } 
 else if(getstr=='l'){  //if a "l" text is read 
 Serial.println("go left!"); // arduino will sent text back "go left"
 _mStop(in1,in2); // turn off left motor
 _mStop(in3,in4); // turn off right motor
 _mRight(in3,in4); // right motor forwards
 } 
 else if(getstr=='r'){  //if a "r" text is read 
 Serial.println("go right!"); // arduino will sent text back "go right"
 _mStop(in1,in2); // turn off left motor
 _mStop(in3,in4); // turn off right motor
 _mRight(in1,in2); // left motor forwards
 } 
 
 else if(getstr=='s'){ //if a "s" text is read 
 Serial.println("Stop!");  // arduino will sent text back "stop"
 _mStop(in1,in2); // turn off left motor
 _mStop(in3,in4); // turn off right motor
 } 
  else if(getstr=='t'){ //if a "t" text is read 
 Serial.println("spin!"); // arduino will sent text back "spin"
 _mStop(in1,in2); // turn off left motor
 _mStop(in3,in4);  // turn off right motor
 _mRight(in1,in2); // left motor forwards
 _mLeft(in3,in4);// right motor backwards
 } 
}

Step 8: Connecting the Bluetooth

Connecting the Bluetooth is simple and then you will be able to drive your robot from your computer without the USB cable. If you look on your Arduino and Bluetooth module you will see the pins labeled TXD and RXD. these are the 2 data lines that we need to use TXD basically means transmit and RXD means receive.

So we want the Bluetooth to transmit a signal so use the TXD pin. Now we want the arduino to receive the signal so and it does this on the RXD pin.

  • So simply run a wire from the TXD pin on the blue tooth to the RXD pin on the arduno.
  • The module will need to be grounded (GRD) and use the 5 volt supply on the arduino to power the module (5v to VCC)
  • Next with need to pair the Bluetooth on your computer to the module, find the Bluetooth menu on your computer.
  • If the module is powered up the should be able to find it automatically.
  • You most likely get an error about the pass key does not match, click on options.
  • The passkey usually is 1234 or 0000
  • The Bluetooth module should now be connected
  • On the arduino IDE select the device from ports it should be something like "HC-05 Dev"
  • You can now sent commands to the arduino via the serial monitor. The robot should move when you sent f,b,l,r, t
  • You will notice that the device will disconnect when the serial monitor is closed and automatically connect when the serial monitor is opened.

Challenges, can you?

You will notice that the serial monitor doesn't write the command (like go forward!) after it has been sent via Bluetooth. Can find out why? Can you fix it?

Can you upload code to your arduino via Bluetooth?

Step 9: Using App Inventer, Start With the Buttons.

If you look at the screen shots you will find notes that you can follow to get the screen set up.

  • Click and drag the list picker icon and drop it onto the screen

  • Change the name using the text box near the bottom of the screen

  • Click on width and fill parent

  • Use the button icon to drag three buttons onto the screen

  • Click on layout and drag the horizontal arrangement onto the screen

  • Click on width and fill parent

  • Drag the buttons into the box

  • Rename the 3 buttons to left, forward and right, using the text box

  • Add another three buttons to the screen.

  • Rename and arrange them on them screen

Step 10: Setting Up the Blocks for Bluetooth

If you open up the photos you will find notes that will help with this step. This is the bit where we program your app to look for a Bluetooth device and and pair it to your robot.

  • The first thing to do is to find the Bluetooth client icon on the left and drag it on to the screen.
  • You should be able to see it in non visible components at the bottom
  • Click on the blocks button.
  • Now in the list picker menu find the "after list picking" block and drag on to the screen
  • In the list picker menu grab the green "set" block
  • Click the "set" block into the list picker block and use the pull down menu find "selection"
  • At the bottom of the page find Bluetooth client button
  • There are 2 Bluetooth client buttons which do different things. Use the top one. Find the purple "call" block with connect and address on the end. Drag it into the screen
  • Go back into list picker menu and find the green " list picker" block
  • Place the list picker block onto the end of the call block. Then from the drop down menu chose "selection"
  • Go back to list picker and drag the green "list picker " block onto the screen
  • Then from the drop down menu chose "selection"
  • Go back into list picker and find the green "set" block
  • While your at it grab the top button from text the " " button
  • click them into the bottom of the other "set" block and use the pull down menu to chose "selection"
  • Type "connected"into the text box, or any other message you want to display when the Bluetooth is Paired with your phone
  • Go back to list picker and find the "before picking" block

  • Drop the before picking block onto the screen

  • In the list picker menu find the green "set" block

  • Click the "set" block into the before picking block

  • From the pull down menu select "elements"

  • From the Bluetooth client menu find the green "address and names" block

  • click addresses and names block into the green set block

Step 11: Adding Buttons to Your App

This step is a little easier, each button has to send a text message to your robot, as long as you use the same letters you used in your arduino code the robot will respond, you also need to remember which button does what or you could have your robot doing something is shouldn't, like driving off when you pushed stop.

  • Click on a button and find the "when click do" block

  • Drop it onto the screen

  • In Bluetooth client menu find the purple "call send text" block

  • Also grab the text box " " block

  • Right click on the "when click do" block and duplicate it

  • You will notice a red cross indicating a conflict because there are two buttons labeled button 1

  • Use the pull down menu to change the button number

  • You can duplicate it again until you have all six buttons

  • Laying out the blocks like the buttons on the screen can make it easier to remember which button does what

  • Change all your button numbers so they go from 1 to 6

  • In the text box blocks type in the letters for each of your commands your used in your arduino code.
    " l, F, R, S, B,T"

  • If its all too hard and you have read down to here you could always cheat and use the code below. Ill know you cheated though ;-0

Step 12: Pair the Bluetooth Module to Your Phone, and Go for a Spin.

Before you upload your App to your phone it is a good idea to pair the Bluetooth module to your phone. Just find the device and the pass key is usually 1234 or 0000. you can then open your app and connect to Bluetooth and it should work. You are then ready to try out your new app

You might find that if you have the wires on the motor around the wrong way it turns backwards, but they are an easy fix.

Where to next?

You can add another layer to your robot, add sensors and program it to do all sorts of things, and there is plenty of help if you google "arduino robot projects" Here's some ideas

  • Add some more batteries for more speed and power
  • Add a servo and attach a flipper to knock over other robots
  • Add an ultrasonic sensor to stop it running into walls.
  • design a rats maze and code a rats maze solving robot.
  • Maybe the rats maze could be black lines on the floor.
  • Robot Soccer team.

  • Add speed control.
  • Robot vacuum cleaner
  • Robot cat chaser.
  • Robot weed wacker.
  • Can you use the phones accelerometer to control the robot (check out the code below) website maybe blocked at school.

Comments

author
chrisjlionel (author)2017-09-12

Well described. Good one.

author

thanks chris

About This Instructable

1,233views

19favorites

License:

Bio: Fixer, Finder, Fabricator.
More by liquidhandwash:Mobile Phone Controlled RobotSplit Grommet for Dishwasher Aqua-stop HoseRat Rod Facelift LED Headlights
Add instructable to: