i'm not really a bumblebee
cookies
romillyhills.co.uk uses cookies! cookies are used for the login system and removing this bubble.
arduino%20rc%20car.jpg
clock21:43 on 10.04.12 eye1366 speech bubble0
after building the usb laser tank i realised any future robot would need to be far more powerful, if for nothing else just to carry batteries. then i remembered i had this old rc car

as you can see this isn't a normal rc car from a toy shop; it's a hobby grade car, which makes it both uber powerful *and* incredibly easy to hack.

the old rc gear in the car treated the steering and the electronic speed controller (ESC) as servos, this obviously meant i could re-use my old servo script.

and i did.

#include

Servo servo1;//rotate servo
Servo servo2;//speed controller

int moo,servo1position,servo2position,rawr;

void setup() {
servo1.attach(14); //analog pin 0
servo2.attach(15); //analog pin 1
Serial.begin(9600);

servo1position=90;
servo2position=90;
rawr=1;//sensitivity
}
void loop(){
if (Serial.available() > 0) {
moo = Serial.read();//read serial data
}
//change servo position based on input
if(moo=='w'){
moo=0;
servo2position=servo2position+rawr;
Serial.print(servo2position);
}else if(moo=='s'){
moo=0;
servo2position=servo2position-rawr;
Serial.print(servo2position);
}else if(moo=='a'){
moo=0;
servo1position=servo1position+rawr;
Serial.print(servo1position);
}else if(moo=='d'){
moo=0;
servo1position=servo1position-rawr;
Serial.print(servo1position);
}
//prevent the servos over-rotating
if(servo1position>=180){
servo1position=180;
}else if (servo1position<=0){
servo1position=0;
}else if (servo2position>=180){
servo2position=180;
}else if (servo2position<=0){
servo2position=0;
}
//set the position of the servos
servo1.write(servo1position);
servo2.write(servo2position);
}


with a few modifications and the arduino serial monitor i was done!

the steering worked fine, it's just a servo doing servo stuff, however the ESC takes a bit of experimentation; a normal servo takes commands ranging from 0 to 180 corresponding to the relevant angle, which would imply that for the ESC 90 would be stop, 0 maximum reverse and 180 maximum forwards, however i found that at 90 the car would start reversing and at about 99 the car would go forwards. just something to look out for.

other then that, that's it! a wasd controlled rc car.
what happened to my arms!?