Tag Archives: Arduino

The Journey to Building Remote Controls

I recently finished a project that involves an Arduino powered remote control. I learned a lot of things along the way about setup and programming that I wanted to share to help others avoid pitfalls.

Xbee Remote 2

Hardware Issues

The Adafruit Xbee breakout board supports directly transmitting analog inputs to a second Xbee receiver. This is great for simple projects, but I was looking for very strict control over the Remote and the Robot. I also had a dream of later using the stick to control an actuator mounted to the robot using the same stick that controls the movement of the robot. This would certainly require a micro-controller on both ends (Or so I thought).

As I look back, I probably didn’t even need an Arduino to handle the Remote Control portion as I could have just handled all the interpolation on the robot side. One unforeseen benefit is that I now have a remote that can be used for virtually any remote project I come up with in the future since all the interpolation has already been programmed.

Software Issues

The library for handling Xbee transmission is fairly easy to use, but I had some issues on the receiver side. I had two major hangups. The first was being able to read the entire string being passed to the receiver.

It took some time to realize that the string was being transmitted character by character. I initially tried the code below but it did not properly read in the entire string.

Receiver Code:
void loop()
{
if (mySerial.available())
{
Serial.println((String)mySerial.read());
}
}

I then tried the code below which was able to read the string, but I could not properly parse the whole string.


Receiver Code:
void loop()
{
if (mySerial.available())
{
Serial.write(mySerial.read());
}
}

Finally, I came to this version of code. It waits for something in the buffer and then reconstructs the string in a loop one character at a time.

while(mySerial.available())
{
character = mySerial.read();
content.concat(character);
}
if (content != “”)
{
content.trim();
Serial.print(content);
}

My last major problem was an issue in the way I was originally transmitting control instructions. I was just waiting for input and then transmitting the input over and over which caused a buffer overload on the receiving side. My code would send the Forward command over and over resulting in the backing up of the receiving buffer. When I then transmitted a stop command, it would often get lost in the flood off control commands.

I remedied this situation by transmitting the control instruction only once and setting a “last sent” flag to check if the command was the same or not. This stopped the flood and only transmitted an instruction via Xbee when it was different that before. This technique can be viewed in the completed code for the Arduino Powered Remote Control Robot project.

Summary

Every project should come with a healthy bit of learning along the way. I learned much more about the hardware and how much of a difference a slight change in code implementation can make to address limitations in the hardware.

Another major learning point of this project was the importance of version control along the way for the purposes of learning. I have always been a back-up advocate, but the evolution of the code is always extremely important. It shows you where you were and where you have come too. Sometimes, it is nothing but a testament to how far you have come, but sometimes it is a road map to help others learn.

Cheers,

Justin

 

Arduino Powered Remote Control Robot

I have been working on a Arduino Powered Robot that could be remote controlled. (I will continue to update this with more detail). The video below shows the prototype robot working via the remote control. This article will describe how I built the Robot, the materials used, and the program that controls it.

Materials List

This project was completed with materials ordered entirely from Adafruit.com. If your not familiar with them, check out their excellent tutorials and supplies for makers.

 

The Remote Control

The remote is a BoArduino from Adafruit attached to a clear breadboard with an Analog Control Knob and a Xbee Series 1 transmitter. The wiring is pretty Simple for the remote. The control knob is wired to the analog pins on the BoArduino along with a +5V and a Ground wire. The Xbee is wired from the RX and TX pins to the Digital 3 and Digital 2 pins respectively along with a +5 and a ground wire. Some of the extra black wires in the picture hold my breadboard wires in place so they don’t pull loose and are not needed.

Xbee Remote 2    Xbee Remote

The Sketch below is the code for the remote. Feel free to download and modify it. Suggestions for improvement are also welcome.

Remote Control Sketch

 

The Wireless Robot

The robot is Arduino powered and Xbee controlled. A program waits for Xbee transmitted commands and then determines which of four continuous motion servos to actuate. The frame is composed of components from an Open Beam kit. The nice thing about Open Beam is that the plastic Arduino mounting plate slides into the sides of each beam. This creates a secure and easy electronics mount. Just place a beam of the appropriate length on each side and secure in place with the Open Beam corner brackets.

Robot_Front Robot_Rear

The picture below shows how everything is connected. The program expects the left side servos to be connected to Pin 4 and the right side servos to be connected to Pin 8. In the picture below, you can see that both servos on the left share the same +5v, ground, and control wire as do the servos of the right. Digital Pins 2 and 3 are connected to the Xbee pins to the TX and RX pins respectively.

Robot_Top

The sketch below contains the program to control the robot via wireless commands received from the remote.

Remote Robot Sketch

This is a work in progress. It was a fun little project and it is quite rewarding to create a remote controlled robot. I plan to add a remote control arm for simple tasks. What would you add to the robot? Thanks for reading. Good Luck building!

– Justin