The other day, well actually quite a lot of days ago, Thomas, one of my twin boys, asked about making an electronic car.  It seems that they might be making an electronic car at school soon, and he wanted to get a head start … awww, bless him, he’s only 8 🙂

So I thought I’d better get prepared.

Now, we didn’t really have much in the electronics box that we could use, apart from an L293D.  This is a DC motor driver, a simple IC that can control DC motors via an H-Bridge circuit.  Now, if we’re going to be connecting up some 5v hobby motors to a microcontroller chip such as an ATTiny45, we need to protect the chip from i) drawing too much current, and ii) problems associated with switching inductive loads such as motors.

An H-Bridge is simply a set of four switches with protective flyback diodes, and the L293D provides a very convenient way to control two motors via a microcontroller chip.  Yay!

Salvaged micro-switchesHowever, it turns out I didn’t have much else …

… apart from a USB missile launcher which hadn’t worked in years … hmmm.  Taking the USB missile launcher apart gave us some wonderful pieces to play with.  Not only did it have two low voltage DC motors, but some very useful microswitches which will come in handy later (I’m thinking of bump/collision detection here!)

So, two motors, three microswitches, ATTiny45, L293D … what else do we need?


Wheel glued to the DC motorOf course.  Good job Thomas had a Konnects building set which just so happened to have some wheels included, and he was happy to donate them to the project.  It was an easy case of gluing the wheels to the DC motors.  Also, I have some standard stripboard which we can use for the chassis and to hold all the electronics.  This is looking good!

Now we have all our bits and pieces, we just need to get started on building the circuit.  The code itself is going to be simply a case of making control pins go HIGH and LOW, though for reading the microswitches I’m going to use another simple technique rather than constantly polling the input pins.

Effectively I’m going to create a resistor ladder with all the microswitches connected into the resitor ladder circuit to act as a voltage divider or potential divider, and then measure the voltage at the input pin relative to the source voltage.  By running an ADC conversion at the input pin, we can determine which microswitch has been pressed.  More on this in a later post.

So, we have all the pieces ready.  All we have to do now is build the circuit, program the ATTiny, and let Thomas take it in to his “show and tell” session at school …

… but first, perhaps, I should wait for Thomas to help me build the electronic robot car, eh? 🙂  That will be the basis of the next post in this series …

Stripboard, ATTiny45, L293D, 5v DC motors, microswitches, wheels ... robot car is ready to build!

2 thoughts on “Electronic Robot Car – L293D – 5v Motors – ATTiny – AVR

    1. Hi David, that’s a good question. A resistor ladder is quite literally a group of resistors connected in serial. You can use this configuration either as a “voltage splitter” or in other words a voltage divider or potential divider, or as a way to do digital to analog conversions.

      The way I’m going to be using it is to put switches off of every junction between the resistors and connect this to ground. Then run an ADC (analog to digital conversion). Because the resistor ladder splits the voltage depending on which switch is closed, you can compare the digital value that’s output and from that work out which switch is closed.

      It’s a handy way of running multiple switches off of a single microcontroller pin.

      I’ll be posting more about this, including circuit diagrams, really soon.

Leave a Reply

Your email address will not be published. Required fields are marked *