Elmwood no more, long live Elmwood! Elmwood Electronics and PiShop are now together!
Please order via PiShop.ca, as we are no longer taking orders through this site.
More details are in our blog!

Red Rover Red Rover, we'll send it right over!

November 09, 2017

Red Rover is a simple 2WD robot chassis that gets your projects moving quickly! Unlike other robots that need expensive motor control boards, Elmwood Electronics' Red Rover comes with a really simple motor controller board. If you can make servos move, you can make Red Rover move!

How it works

Red Rover's motor driver board makes the wheel drive motors appear as two continuous rotation servos:

So you'll be able to use your micro-controller's standard servo library to drive Red Rover. Set the motor to 180° and it'll drive at 100% forward. Set it to 0°, and the motor will run backwards at full speed. Set it to 90° and it stops.

Example Code

We drove Red Rover through an Arduino Uno powered by 4 AA batteries in a  battery holder. The following code contains a couple of helper functions to make it easier to drive your Red Rover:

 

/*
   Red Rover Trundle Plot - tape a marker to your Red Rover
       and it draws a flower-like figure

   Plot **should** stay within 450 × 600 mm (US Arch C) pad
   and likely will fit ISO A2 pads, but **test first**
   and don't blame us for any stainage …

   Rover motors appear on Arduino as two servos on pins 5 & 6

   scruss - 2017-11 - for Elmwood Electronics, elmwood.to
*/

#include <Servo.h>

Servo lefty, righty;

/*
   drive - helper function to map motor speed (-100…100%) to
       Servo.write() input range (0…180°)

   Input:
       < 0 : reverse
         0 : stop
       > 0 : forward

   Output:
         constrained to valid Servo.write() input range

   Red Rover controller has effective deadband/ stop band
       of 87…93°, but requesting very low speeds may not
       result in expected motion

   Uses integer maths, so expect rounding/truncation.
*/
int drive(int speed) {
  if (speed < 0) {
    // reverse: -100…0% → 0…87°
    // inputs *and* outputs need to be constrained to valid range
    //     as map() does no range checking
    return constrain(map(constrain(speed, -100, 0), -100, 0, 0, 87),
                     0, 87);
  }
  if (speed > 0) {
    // forward: 0…100% → 93…180°
    return constrain(map(constrain(speed, 0, 100), 0, 100, 93, 180),
                     93, 180);
  }
  // default: stop
  return 90;
}

void setboth(int left, int right) {
  // helper to set both left & right motors between -100…+100% speed
  lefty.write(drive(left));
  righty.write(drive(right));
}

void setup() {
  lefty.attach(5, 1000, 2000);  // left  servo: pin 5
  righty.attach(6, 1000, 2000); // right servo: pin 6
  setboth(0, 0);                // initial state is stopped
}

void loop() {
  // veer right forwards by setting left motor a bit faster (75%)
  //     than the right motor (60%)
  setboth(75, 60);
  delay(750);         // trundle merrily onwards for ¾s

  // now stop abruptly
  setboth(0, 0);
  delay(250);         // give it ¼s settling time

  // veer left backwards: right now faster than left
  setboth(-60, -75);
  delay(750);         // same backwards trundle time as forwards,
  //                     else Red Rover spirals off into shrubbery

  // stop abruptly again and settle
  setboth(0, 0);
  delay(250);
}

(code on github: redrover_trundleplot.ino)

Tape a pen to it, place it on a big pad of paper, and this is what you'll get!

We're planning to do more with Red Rover, so please check back and see what we've come up with.





Also in News

Elmwood no more, long live Elmwood! Elmwood Electronics and PiShop are now together!

October 03, 2022

Elmwood no more, long live Elmwood! Elmwood Electronics and PiShop are now together! Please see our blog for more info.

Continue Reading

Adding RGB LEDs to an illuminated arcade button

March 14, 2022

Continue Reading

We Made a Media Controller!

October 12, 2021

Continue Reading