I made my first microcontroller based robot over the weekend. It is far from finished. But it can drive around randomly. Getting something to move randomly was harder than it should have been. I realised overnight that I don’t actually need a random number generator if I want it to appear to move randomly. I just need to use any function that is chaotic.

The motors are controlled using two h-bridges. I’ve used BD139 and BD140 transistors. They can handle a continuous current of 1.5A. That will be enough for the toy motors I am using.

A PIC16F505 Microchip microcontroller is the brains behind my robot. It’s a pretty limited chip. It has room for 1024 12-bit instructions and 72 bytes of RAM. I’ll replace it once I need some extra functionality. I started writing the code in C but I had lots of problems with it. Certain math functions seem to freeze up and I kept getting confusing errors. So I’m re-writing it in assembly using gputils.

As you can see, there isn’t much to it. Eight transistors to control two motors with a few diodes and resistors and the microcontroller. The container has lots of room to add a big PCB later. In the top right corner you can see a capacitor with the battery leads connected to it. That’s the power switch. When I want to turn it on I plug that into the breadboard. It’s a bit crude, I’ll probably plug it in the wrong way or in the wrong place and fry everything knowing my luck.

I have a few plans for this little robot in the future. I want to give it more brains than any lunch box should ever have. It’ll be able to create maps and mark locations of interest. I’ll attempt to make it appear curious so when it finds something it hasn’t seen before it will keep going back until it isn’t new anymore. Hopefully I’ll make more than one and have them communicate via beeps or flashy lights. Then they can follow each other around and have twice as much fun.

I also want it to be able to recharge itself by homing in on a charging station that sends out a beacon.

I only had a 8-bit “random” number generator when I videoed this. So It repeats itself twice in that short time.

Advertisement