Arduino Rumble Robot Hack

Posted: April 30, 2013 by wehrsteve in Phys II Projects

Arduino Controlled Rumble Robot Hack

Based on http://www.dinofab.com/rumblebot.html

IMG_1103

1. Components

This project involves hacking a Rumble Robot, remote control robot toys from the early 2000’s. You can find them at garage sales or any place that sells old toys. Because I live in Alaska, I went with eBay. An Arduino is required. You will also need a ping sensor of some form. The guide I was following from DinoFab suggested using a Parallax ping sensor. But I’m a rather cheap person and instead got an HC-SR04 ping sensor. It required a few variations in the code and wiring, but worked acceptably. You also need a bump switch, which can be purchased, but I cobbled one together from a can of soda that had the misfortune of being on my desk that night and a similarly unfortunate mechanical pencil. Other than these things everything could be scavenged from the torn apart pieces of the rumble bot.

Tools used include a soldering iron, needle nose pliers, wire strippers, and small screwdriver. A hot glue gun definitely comes in handy, but tape would also suffice. Another thing that could be used to clean up the overall creation is a Dremel tool, but once again, not required.

 

2. Assembly

The first thing to do is take the head off and gut it. DinoFab does an excellent job of demonstrating how to do that, so just follow the link I put near the top if you want to see a video of the whole project. He also does a much better job than I could for the whole wiring into the robot part, so I will talk about my deviations from his superlative plans. First I’ll explain the makeshift bump switch.

IMG_1107

I made the bump switch by cutting a pop can’s top and bottom off so I was left with the main cylindrical part. I flattened this and tried a few different ways to get a solid connection. Turns out, soda cans have a plastic coating on the inside that needs to be scraped off to expose the metal for a direct connection. I ended up doing a basically flat piece with a bend in the tip to touch another piece with both wired separately. The flat piece was glued to a spring from a mechanical pencil in such a way that when the switch hadn’t hit anything it was in contact, completing the circuit. When it bumped into a wall or object, the switch would open the circuit, telling the robot to back up and turn around.

IMG_1109

The next thing to talk about is the use of the ping sensor, HC-SR04. The wiring needed to change slightly to accommodate the extra wire needed for the HC-SR04. This is a difficult step to explain, so I will use the picture of my wiring setup. There was a little bit of coding to do, with the changing of variables, but if you use my code with my wiring it should work. I used the code from <a href=”http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/step3/Upload-the-sketch/“>http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/step3/Upload-the-sketch/</a>. and subbed it into the spot in DinoFabs code where we would normally have used the Parallax sensor. Instead of having it read the value out like in the instructable, I just set the “if, then” statement to run the motors like in the original code.

IMG_1108

3. Finishing Details

I filed the eyes out of the robot and placed the ping sensor in them. The bump switch was placed in a “nose” spot. I also tore the bottom apart and made holes in order to look at the moving gear system inside it. And using one of the original switches from the robot, I set a switch up to my power supply, so it isn’t left on all the time. I am not sure if he talks about it in his video, but you can wire the power from the batteries directly into the Arduino by running a wire from the power pin in the belly of the robot. I think its either the second or third in from the right on the ribbon wire connector. And its only 6V, but I believe you can power an Arduino with anything from 3V-20V.

 

4.Coding

Grab this code and throw it into a sketch. Should work fine. If you are using an actual bump switch, the LOW and HIGH checks may need to be swapped.

/* Rumblebot Driving with object avoidance utiliszing PING Ultrasound Sensor

* and a bump switch.

* Reads values (00014-01199) from an ultrasound sensor (Parallax PING)

*

* Version 1.1.2 Motor runs and drives full time unless object detected.

*——————————————————————–

*

*

*

*

*

*

*/

int switchPin = 2; // Right bump switch on pin 2

int swval; // Variable for reading switch status

int motorpinright = 6; // pin for left motor reverse

int motorpinleft = 11; // pin for left motor forward

int motorpinrevright = 5; // pin for right motor reverse

int motorpinrevleft = 10; // pin for right motor forward

int trigPin = 12; // trigger pin

int echoPin = 13; // echo pin

 

void setup() {

pinMode(switchPin, INPUT); // Sets the digital pin as input

pinMode(motorpinright, OUTPUT); // Motor drives———–

pinMode(motorpinleft, OUTPUT); //————————

pinMode(motorpinrevright, OUTPUT); //————————

pinMode(motorpinrevleft, OUTPUT); //————————

 pinMode(trigPin, OUTPUT);

 pinMode(echoPin, INPUT);

 

}

 

void loop() {

 long duration, distance;

 digitalWrite(trigPin, LOW);  // Added this line

 delayMicroseconds(2); // Added this line

 digitalWrite(trigPin, HIGH);

//  delayMicroseconds(1000); – Removed this line

 delayMicroseconds(10); // Added this line

 digitalWrite(trigPin, LOW);

 duration = pulseIn(echoPin, HIGH);

 distance = (duration/2) / 29.1;

 if (distance > 75) {  // straight

analogWrite(motorpinleft, 255); //100% speed

analogWrite(motorpinright, 255); //100% speed

}

 else { // turn

analogWrite(motorpinleft, 0); //stop left motor

analogWrite(motorpinright, 0); //stop right motor

analogWrite(motorpinrevright, 0); // stop right rev motor

analogWrite(motorpinrevleft, 0); // stop left rev motor

analogWrite(motorpinrevright, 255); //100% speed

analogWrite(motorpinleft, 255); //100% speed

delay(380); //380 milliseconds

analogWrite(motorpinrevright, 0); // off

analogWrite(motorpinleft, 0); // off

 }

{

 delay(50);

}

/* Backup and turn right when switch gets bumped and closes circuit to ground

*—————————————————

*/

 

//digitalWrite(switchPin, LOW); // Sets the pin to high

swval = digitalRead(switchPin); // Read input value and store it

if (swval == HIGH) {

analogWrite(motorpinleft, 0); //stop left motor

analogWrite(motorpinright, 0); //stop right motor

analogWrite(motorpinrevleft, 0); // stop left rev motor

analogWrite(motorpinrevright, 0); // stop right rev motor

analogWrite(motorpinrevleft, 255); //100% speed

analogWrite(motorpinrevright, 255); //100% speed

delay(800); //800 milliseconds

analogWrite(motorpinrevleft, 0); // off

analogWrite(motorpinrevright, 0); // off

analogWrite(motorpinrevright, 255); //100% reverse speed

analogWrite(motorpinleft, 255); //100% forward speed

delay(700); //700 milliseconds

analogWrite(motorpinrevright, 0); // off

analogWrite(motorpinleft, 0); // off

delay(50); //50 milliseconds

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s