Tuesday, 28 August 2012

Robot Insect

I purchased a book called Make: Arduino Bots and Gadgets: Six Embedded Projects with Open Source Hardware and Software (Learning by Discovery) by Tero Karvinen and Kimmo Karvine. One of the projects in there was a simple robot insect which I decided to have a go at creating. The book is quite good with detailed explanations but I didn't follow the instruction exactly and the parts list are for US only. The insect uses two servo motors to move coat hanger wire front and rear legs. I looked for servo motors but most seemed quite expensive (£10 ea or more) but I found UK Arduino specialist oomlout.co.uk sell 'mini' servo motors for £5 each so I ordered a couple.
These are really quite small but appear to do the job. The book suggests using a hot glue gun to glue the two servos together with the front one facing forward and the rear one facing down. I don't have a hot glue gun so I used my old favorite, 'gaffer' tape.
This picture shows the two servos taped together and the rear legs made out of coat hanger wire, and attached to the servo mounting part using thin wire (I also taped a thin strip of gaffer taped over these). For Arduino board itself and the battery I used a small piece of MDF and used cable ties to attach the servos to the MDF. End result looked like this:
Before you attach the legs to the servos you need to center the servos using a very simple sketch. Once the legs are attached you can download the full walking program. I found the some adjustment to the shape of the legs is neeed to get it to walk. I also found it only works on carpet, not on smooth flooring such as laminate or lino as the legs get no grip. I added the wall plug feet to help with the grip, these are not mentioned in the book and some other sort of rubber feet might work better. This video shows it walking:
The sketch required to center the servos is shown below:
This must be uploaded to the Arduino with the servos attached but before the legs are attached to the servos, otherwise the legs may end up mis-aligned.
The sketch that makes the robot walk is as follows:
This basically goes though a loop of raising the front right leg, followed by the back left, then front left leg followed by back right.


Saturday, 25 August 2012

Fritzing

Fritzing is a great free tool for creating breadboard diagrams. Much better than the photos I have used so far. You can download it here

Here is the diagram for the motor controller for a single motor, done in Fritzing:

I will add the two motor one shortly. Its a good way to document your projects as well as show other people what you did,

Wednesday, 22 August 2012

Computer controlled vehicle

Having tested out the motor controller its now time to put them together to make a simple vehicle. To try this out I just stuck the two robot feet together with gaffer tape:
I used some longer wires to connect them up to the Arduino so they could move around a bit.

I wired up a second motor controller on the breadboard, same as the first one. I made a video of doing this, which you can see here

I then wrote a more sophisticated version of the original sketch which allows me to send commands to the Arduino to get the vehicle to stop and go (as before) and turn right and left. Here it is:


//left and right motors
int motorPinL = 9;
int motorPinR = 10;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pins as an output.
  
   pinMode(motorPinL,OUTPUT);
   pinMode(motorPinR,OUTPUT);
   Serial.begin(9600);
  } 

// the loop routine runs over and over again forever:
void loop() {
  
  if (Serial.available() > 0)
  {
    char ch = Serial.read();
    // press 'g' to go:
    if (ch == 'g')
    { digitalWrite(motorPinL, HIGH);
      digitalWrite(motorPinR, HIGH);
    }
    if (ch == 's')
    // press 's' to stop:
    {digitalWrite(motorPinL, LOW);
    digitalWrite(motorPinR, LOW);
    }
    if (ch == 'r')
    // press 'r' to run just one motor:
    {  digitalWrite(motorPinL, LOW);
      digitalWrite(motorPinR, HIGH);
    }
    if (ch == 'l')
    // press 'l' to run the other motor:
    {
    digitalWrite(motorPinR, LOW);
    digitalWrite(motorPinL, HIGH);}
  }
}

This video shows the vehicle working:

All very well but now I need to look into how to make the vehicle more autonomous, so for example it can avoid obstacles.

Better photo

Here is a better photo showing the wire connections from the breadboard controlling the single motor:

Transistors and motors

To turn electric motors on and off with the Arduino you really need a transistor, none of which came in the starter pack I bought.

I found some TIP122 transistors in the loft at home (left over for a previous unsuccessful foray into electronics many years ago), and when I Googled 'TIP122 and Ardunio', it came up with a very simple motor control circuit using a TIP122 - here

For some motors I dismantled an old robot toy (sorry kids!). It has a small 3v motor in each of its feet.
I build the circuit on a separate breadboard (the one in the kit is really too small!) and wrote a very simple motor control sketch, just to try it out. This is the circuit I built:

 This is the sketch I wrote to turn the motor on and off:
To make it work, you open a serial monitor window. Type 'g' and the motor will start running, type 's' and it stops. Simple! Next, I will put the two robot feet together and create a 4 wheel vehicle which I can steer left and right.

Monday, 20 August 2012

Arduino, Raspberry Pii etc.

This blog is about my interest in Computer Science in Education. I am an FE lecturer who teaches programming and computer hardware. I am always keen to investigate new areas and new ways to teach and enthuse my students about computer science. I'm no expert, most of what I will write about here is my own efforts to teach myself more about his topic.

Currently I am developing my skills in programming and robotics using the Arduino board (you can read lots about the Arduino here). I only received the board a couple of weeks ago so I haven't got very far with it, but I am hoping to explore the area of robotics with it.

I ordered the Arduino starter kit from Proto-PIC via Amazon (details here). This comes with a small breadboard and some components. I made a little base to hold both the Arduino and the breadboard and got started with the examples off the Ardunio web site (see here).
I pretty soon discovered that although the kit is a good starter its pretty limited as it does not have any transistors or motors. So I had to search elsewhere for these...

(In case you are wondering why I mention the Raspberry Pii, I have one on order, It has been on order for some time! As soon as it arrives I will post some experiences with it here)