Let's Make Robots!

Penny - An Arduino SHR

starthere1.0.pde3.38 KB
starthere1.2.pde3.88 KB

Introducing Penny. She's beginning her existence as a Start Here style robot. However, she's based on an Arduino Mega.

  • Video 1: Early testing of the servo and Sharp IR sensor used to test my code.
  • Video 2: Penny prototyped on a breadboard and running fine


I re-used the motors, wheels and chassis from my original SHR, which has been gathering dust for a while.

Penny is configured back-to-front from the old SHR, with her drive wheels in the lead. I set the Sharp IR sensor back as far as practical, since it doesn't work well closer than 10 cm anyway.

The messy breadboard will get cleaned up. I plan to use Ro-Bot-X's Arduino shield for building robots, which will take care of .some of that wiring for me.

Update 2010-10-05: I have received the Ro-Bot-X designed Arduino shield and gave Penny an upgrade. Look at her now. Quite a difference!


Penny 1.0 is based on a straight translation of fritls' Start Here code for the Picaxe. This is my first Arduino robot, so I wanted to start simple. I'm very pleased with the result.

I have attached the original code as well as an updated version that is fit for the Arduino shield and adds a backup function.


I'm using an SN754410NE dual h-bridge motor driver. No other electronics yet.


As you can see in the 2nd video, Penny is working fine. I adjusted some parameters, like how far away she reacts to an obstacle. There's plenty of room for enhancement of the basic SHR code, and I'll use Penny as a platform for learning more about  the Arduino.


The future is bright for Penny. I have a lot of possible enhancements with an Arduino Mega as the brain power. We may see features like:

  • Wheel encoders
  • PWM
  • Line following
  • Edge/cliff detection
  • More actuators
  • Perhaps... penmanship

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Code!!! We want to see the code!! (Or at least I do...  :P )

Also, what are you using for motor drivers? 

Hey my friend,I like your robot,well done and great video explanations. It's good to have comments while the robot is running.

Thanks for posting and I'll keep an eye on your projects for sure :)

You look like a nice and cool guy.  By the way would the code work on the arduino Duemilanove too?

Yes it will. You just have to change the analog pin number from 54 to whatever you are using on the Duemilanove.

I'm only using the Mega because it is what I have. It's HUGE overkill for this robot.

Strange coding though...

On the duemilanove you would need to address the pin with it's "pin number" when using pinMode and digitalWrite, while you would use a number from 0 to 5 (duemilanove has 6 analog inputs) when using the analogRead. I'll explain myself better: let's say you want to set the first adc pin as input and activate internal pull-ups, you would do something like this:

pinMode(14, OUTPUT);

digitalWrite(14, HIGH);

and to read from the SAME analog pin you'd write:


For pinMode and digitalWrite you gotta start counting from the first arduino pin, and analog ones come right after. For analogRead you start counting from 0, which represents the first pin. You may want to write it down in case you want to make an arduino-based SHR so that folks using duemilanoves can get it working :=)

ps: you probably know this much better than me...main purpose of my post was just reminding :=)


Actually, since I'm totally new to the Arduino, it is an interesting point. I read that about the Duemilanove. When it came time to code, I figured out I would need to use pin 54 for my pinMode and digitalWrite commands to set the pullup high, just as you say. But why declare a second variable just so the pin matches the printing on the board?

Since I wasn't used to this convention, I kept it simple and used the same variable storing '54' for the analogRead command as well. It worked fine, but it is helpful to know that Arduino convention is as you describe it. Thanks for the education. ; j


I just thought you couldn't adress the pin the same way as you did with pinMode/digitalWrite. That's what the reference on arduino.cc says: 

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)

...guess they gotta update it! :=)

You can use both, the digital pin number or the analog channel number. See the Arduino code:


int analogRead(uint8_t pin)
        uint8_t low, high;

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
        if (pin >= 54) pin -= 54; // allow for channel or pin numbers

        // the MUX5 bit of ADCSRB selects whether we're reading from channels
        // 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
        ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
        if (pin >= 14) pin -= 14; // allow for channel or pin numbers

I prefer to use the analog channel number. BTW, nice job ignoblegnome, Arduino rules.

Thanks for your help both :)