From NURDspace

Revision as of 21:35, 31 March 2012 by Bjornl (Talk | contribs)

Jump to: navigation, search
NURDspace Project
Participants Bjornl, Buzz
Tool category
"{{{Name}}}" cannot be used as a page name in this wiki.
"File:{{{Picture}}}" cannot be used as a page name in this wiki.

{{{Picture}}} {{#if:{{{Tool}}} | [[Tool Owner::bjornl buZz | }} {{#if:{{{Tool}}} | [[Tool Cost::{{{Cost}}} | }}

buZz has an autonomous electric toy car, "Frank". Frank should be upgraded with sensors to avoid collisions and software to act more intelligently (and possibly execute small furry animals simple tasks).

This is probably a good way to get acquainted with Arduino programming.

  • create new, more intelligent programs
  • add sensors and programming for those sensors


  • 29/02/2012: Attached a Devantech SRF04 Ultrasonic Range Finder to Franks Arduino and got readings! Now working on more intelligent code.
  • 01/03/2012: Uploaded code (see below), works, but _only_ when USB cable is attached, otherwise Frank _always_ retreats!
  • 14/03/2012: Works! Unfortunately there's an electrical problem somewhere in the steering and/or engines, so Frank does not steer well. Next step will be either to try to fix that or get another RC car.
  • 17/03/2012: Steering is done by a stepper motor, it seems. Maybe we can drive the motors directly by using a Motorshield. Info on stepper motors with six wires, like the one in Frank:
  • 30/03/2012: ID found out that Frank does not have a stepper motor, but a "normal" DC motor and a sensor system to detect the position of the steering system. We also got another car, Nicky, who is easier to use because of the steering: this is done by electromagnet instead of a motor.
  • 31/03/2012: It turned out that the Arduino we used has a problem after all. So we used another Arduino + the Motorshield and lo and behold! everything works! So we now have a small, autonomous car! As soon as the battery has been recharged, we'll shoot some video :-)
  • video:


Semi-intelligent steering for RC car
  • /
  1. define NO_MEASUREMENT 0
  2. define TOO_CLOSE 2000
  3. define QUITE_CLOSE 5000
  4. define NOT_SO_CLOSE 15000
  1. define CAREFUL_FORWARD 200
  2. define STEP_FORWARD 400
  3. define RUN_FORWARD 800

// these pins are connected straight to the receiver chip of the RC car const int leftPin = 2; const int rightPin = 3; const int fwdPin = 4; const int bwdPin = 5;

// between this pin and ground, there is a roller ball switch const int rollerPin = 13;

// little 5mm led, red :) const int ledPin = 8;

// rangefinder const int triggerPin = 9; const int echoPin = 10;

void setup() {

 // set up the outputs
 pinMode( leftPin, OUTPUT);
 pinMode(rightPin, OUTPUT);
 pinMode( fwdPin, OUTPUT);
 pinMode( bwdPin, OUTPUT);
 pinMode( ledPin, OUTPUT);
 // set up the inputs
 pinMode(triggerPin, OUTPUT);
 pinMode(echoPin, INPUT);


void loop() {

 int measurement;
 // Get a measurement
 measurement = getMeasurement();
 if (measurement == NO_MEASUREMENT) {
   // No valid signal was given, panic!
 } else if (measurement < TOO_CLOSE) {
   // Too close to wall, retreat!
 } else {
   // Determine amount of time to run forward
   int runTime;
   if (measurement < QUITE_CLOSE) {
     runTime = CAREFUL_FORWARD;
   } else if (measurement < NOT_SO_CLOSE) {
     runTime = STEP_FORWARD;
   } else {
     runTime = RUN_FORWARD;


void panic() {

 // flash LED
 for (int i = 0; i < 10; i++) {
   digitalWrite(ledPin, HIGH);
   digitalWrite(ledPin, LOW);


void retreat() {

 // Go backward left for the given amount of time
 digitalWrite(rightPin, HIGH);
 digitalWrite(leftPin, LOW);
 digitalWrite(fwdPin, LOW);
 digitalWrite(bwdPin, HIGH);
 digitalWrite(bwdPin, LOW);
 digitalWrite(rightPin, LOW);


void goForward(int runTime) {

 Serial.print("Forward: ");
 // Go forward for the given amount of time
 digitalWrite(fwdPin, HIGH);
 digitalWrite(bwdPin, LOW);
 digitalWrite(rightPin, LOW);
 digitalWrite(leftPin, LOW);
 digitalWrite(fwdPin, LOW);


int getMeasurement() {

 Serial.print("Measurement: ");
 int measurement;
 // wait for some time, make it look like we are thinking ;)
 // send trigger pulse
 digitalWrite(triggerPin, HIGH);
 digitalWrite(triggerPin, LOW);
 measurement = pulseIn(echoPin, HIGH);
 digitalWrite(ledPin, LOW);
 return measurement;


/* end */

Our site is hosted by Site4U
Our connectivity is made available by BIT
To BIT's website