Intro: Affordable Phone Controlled Rover
A while back I made a phone controlled rover using the MotorAir. I wanted to revisit the basic idea but using cheaper, more widely available parts. Also since this is Arduino based, it is a great springboard for more than just a rover that drives around. You could add sensors, servos, etc to really drive this project in any direction you want (see what I did there?).
Step 1: Create the GUI
This project uses remotexy.com which is a really cool service that gives you a drag'n'drop GUI creator to make your own app to control your robotics project from you mobile device. This makes this project doable for a lot of people for whom it might otherwise be out of the reach of. It can work with a variety of microcontrollers (mostly arduino) and wireless techniques (Bluetooth, WiFi, the cloud, Ethernet-- ok that one is not wireless).
I went with a 5V Arduino Pro Mini and HC-05 because I already had them from other projects. Although the HC-05 is only Android compatible so if you have an Apple device you may want to use the HM-10 instead. Thankfully their library abstracts and encapsulates all the idiosyncrasies of working with all of those different technologies so you can focus on the GUI and the parts of your project that are unique!
So first I selected the configuration I wanted (what boards I was using). Next I dragged the control elements I wanted in from the left column and set some properties for them in the right column. Then I clicked the green Get Source Code button and voila, the bulk of the work was done for me. I installed their library into my Arduino IDE, downloaded the code that was generated and began working on it locally in my IDE.
Step 2: Customize the Code
The code that RemoteXY created for us is taking the coordinates of a virtual joystick and making that accessible to our Arduino sketch.
Now we need to add some additional code to do something based on the joystick's location. Basically the sketch includes...
- the RemoteXY code which is everything you need to get the virtual joystick coordinates
- a mix function to mix the X and Y coordinates
- a move function to send commands to the motor controller
in the loop function the code gets the current X and Y joystick coordinates, mixes them to determine the speed each motor channel should be going and then sends a command along to the motor controller to rotate in that speed and direction.
If you are using an Arduino Pro Mini you will need an FTDI breakout board before you can upload your sketch to your Arduino because the Arduino Pro Mini does not have a USB port. Simply use the FTDI as go-between between the USB and your Arduino.
You can get the code I used here: https://create.arduino.cc/editor/jjaeger/18e23720-93c7-4e16-b671-3d0a84b3fa11/preview
Step 3: The Electronics & Wiring
In this project I used an Arduino Pro Mini (5V), a TB6612FNG motor controller, and a HC-05 bluetooth adaptor. All together, I spent under $13 on these parts... though I purchased them about 1.5 yrs ago and the place I got them from no longer carries them. But take heart, they can still be found on Amazon and other online stores fairly cheaply if you shop around. You of course get a better per-board price if you can find a multi-pack which works would well if you make a custom board to plug them all into since that comes in a 3 pack. Also all these boards are very versatile and having a few extra lying around (or to use as replacements if you let the smoke out) is quite worth it in my opinion.
The TB6612FNG motor controller is a great motor controller for any of the Runt Rover chassis because the motors used in them only pull 0.25A at stall and that motor controller can handle 1.5A per channel.
I originally tested this with jumper wires plugged into a solderless breadboard but then cleaned it up by having a board made at OSH Park. This made it cleaner, more compact, and more durable. Now I just need to plug my components in when I want to use them or I can easily pull them out to borrow for another project.
Step 4: The Chassis
I was excited to use the 6xAA battery tray which has a 9v battery connector at the top because 9v is right in the butter zone of most Arduino boards. I wanted it out of the way but easy to access. I decided using some magnets would be a slick way to mount the battery tray. So I drilled a hole in the battery tray to firmly mount a magnet, I hid the square nut inside of one of the springs... it is a little snug but works very well.
To mount the other magnet on the inside of the chassis I found (of all things) a timing belt mount works perfectly. Since opposites attract I used one magnet that is countersunk on the north side, and one that is countersunk on the south side. The flat head screws I used to mount them fit the countersink perfectly. I covered the magnet on the battery tray with a few layers of electrical tape. This will reduce the strength of the attraction just a little, and give it just a bit of cushioning when they go together, and if for some reason one of the magnets breaks, it should make it an easier clean-up job.
Step 5: Pair the App to Your Project
So your GUI is created, your code is written and upload to your Arduino, and you project is wired up. Now it is time to apply power to your project by connecting the battery. Next you will need to pair your project to your phone like you would for any bluetooth device. On my Android phone (running Android OxygenOS) I needed to swipe down twice from the top of the screen, click the gear, then Bluetooth, and select HC-05 from the list of available devices. Then I entered the PIN which was 1234.
Step 6: Open the App and Drive!
Once you have paired your phone and bluetooth project open up the Remote XY Free app (if you have not already, now is a good time to install it from the Google Play Store). If this is your first time running it you will need to click the + button in the top right, choose bluetooth, then select the HC-05 from the list. In the future, when you open the Remote XY app you will see a blue HC-05 button that you tap to enter the project interface.
Once you've entered the GUI you designed earlier, you can drag the joystick around and your rover should start moving! Congratulations! You know have made your own phone controlled rover! Once you are familiar with this setup you can start brainstorming ideas for your own add-ons and enhancements to take this simple rover to the next level.