Featured Posts

Balancing robot – without gyros

Posted by Mike Redrobe | Posted in Arduino, robots | Posted on 25-05-2012

Tags: , , ,


Bot balancing without gyros … for a few seconds at least

No gyros, no accelerometers – only a sonar ranger and lots of code.

The motors used are standard servos modified for continuous rotation, sonar sensor is a HC-SR04 as detailed in a previous post

Code ? Well here’s a simplified portion of the PID loop:

    int Drive = 0; // PWM value sent to Servos
    int Error[5]; // array of 5 Error elements
    int P = 0; // proportional term
    int I = 0; // integral term
    int D = 0; // derivative term

    #define Current 0
    #define Sum 1
    #define Last 2
    #define SecondToLast 3
    #define Delta 4

    int PID() {
    Error[Current] = SetPoint – Ptime;
    P = Error[Current] * Kp;
    Error[Sum] = Error[Current] + Error[Last] + Error[SecondToLast];
    I = Error[Sum] * Ki;
    Error[Delta] = Error[Current] – Error[Last];
    D = Error[Delta] * Kd;
    Drive = P + I + D;
    Error[SecondToLast] = Error[Last];
    Error[Last] = Error[Current];

    return Drive;

Ultrasonic robot avoids walls

Posted by Mike Redrobe | Posted in Arduino | Posted on 21-05-2012

Tags: , ,


Using an ultrasonic sonar ranger to avoid walls – and people’s feet – before hitting them:

At first I was getting plenty of false readings, so here’s the first run, pausing and verifying before turning:

With faster code, and not stopping:

Improved accuracy, so it detects smaller objects like feet:

Arduino and SR04 ultrasonic sensor – robot eyes !

Posted by Mike Redrobe | Posted in Arduino | Posted on 20-05-2012

Tags: , ,


Hooked an SR04 ultrasonic sensor to my arduino board – robot eyes !

Ranger sensor uses sonar to give accurate distance measurement to objects or obstacles placed in front of it. They’re surprisingly sensitive / accurate – I was able to reliably measure to a millimeter at 15cm range.

These sensors are also now VERY cheap £2.37 (4$) delivered from HK, and accurate to a few mm.

Added a servo for visual feedback:

Arduino code is basically sending a trigger on one pin, receiving a timing value on another,
which can then be converted into a distance:


    digitalWrite(Trig_pin, LOW);
    digitalWrite(Trig_pin, HIGH);
    digitalWrite(Trig_pin, LOW);
    duration = pulseIn(Echo_pin,HIGH);

Arduino Starter Kit

Posted by Mike Redrobe | Posted in PC Hardware, Technology | Posted on 01-03-2012



Well, what is Arduino ?

Arduino is an open-source platform for microprocessor projects, or as the Arduino website puts it:

“Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.”

Basically its a little CPU that you can program in C, and easily attach servos and sensors to. The open-source nature means there’s a wealth of example code and libraries out there to modify for your own use.

Available in the UK from oomlout for around £50

So what do you get ?

  • Arduino Prototyping Bundle (Arduino Uno board (328), breadboard & acrylic holder)
  • 75 Piece Jumper Wire Bundle
  • Printed 29 page Experimenter’s Guide
  • 11+1 Breadboard Layout Sheets
  • USB Cable
  • Multi-compartment Plastic Storage Box
  • 9v Battery – Arduino Adapter
  • Loads of components
    • 5mm Red LEDs (x10)
    • 5mm Green LEDs (x10)
    • 10mm Red LED (x1)
    • Toy Motor (x1)
    • Mini Servo Motor (x1)
    • 8-Bit Shift Register (74HC595) (x1)
    • Piezo Element (x1)
    • Pushbuttons (x2)
    • Potentiometer (10k) (x1)
    • Photo Resistor (x1)
    • Temperature Sensor (TMP36) (x1)
    • Relay (5v DPDT) (x1)
    • Transistors (2N222A) (x2)
    • Resistors (560 Ohm x25, 2.2k Ohm x3, 10k Ohm x3)
    • Diodes (1N4001) (x2)

The manual goes through 11 projects, from a simple blinking LED to using shift registers and relays, as well as giving a brief overview of how to program for the board and some more complicated tasks after you’ve built each of the individual projects (such as making the blinking LED fade instead).