Follow me




TinyRover - ATtiny85 based obstacle avoiding rover

After a playing session with a Raspberry Pi, I decided to enter into the world of Arduino. To be more precise, I was seduced by ATtiny85 microcontroller size, which is compatible with Arduino IDE.


If you want to know more…

If you want to know more about ATtiny85 microcontroller and how to upload sketches to it, you may have a look to ATtiny85 vs ATmega328.

Required items

For the mobile part, I went simple and used MovingRaspi frame. Thus electronic part seems (OK, is) really small (a compact rover as I previously said). Other part are standard ones:

  • An ATiny85 for the logic of the rover.
  • An L293D motor driver.
  • A Sharp GP2Y0A21YK0F infrared proximity sensor.
  • A L78S05CV voltage regulator to get +5V from the battery pack, and power ATtiny85 (which supports from +1.8V to +5.5V), L293D, GP2Y0A21YK0F and motors.

About motors driving, we have to use 3 pins from L293D per motor: one pin to enable the motor, one pin to make it rotate in one direction, one pin to make it rotate in the other direction. Thus you need 6 pins, which is higher than ATtiny85 available I/O. There's an easy trick: you may always enable motors (with doesn't mean they'll run all the time, you then have to play with the to pins dedicated to rotation direction) by wiring them to +5V line. Then you only need 4 pins from ATtiny85 which will drive rotation direction.

Now you have to use proximity sensor. It need to be wired to +5V and ground. You should add a 10µF capacitor between +5V and ground to filter noise. As I didn't have one of it, I used four 0.1µF capacitors (parallel wiring) which seems to be enough. The third connector is an analog input, which give voltage depending on the distance of the front obstacle (greater distance means lower voltage). But if you look at component's datasheet, you may see two things:

  • Voltage response is not linear. Formula to get distance from voltage is: 65.0 * volts^(-1.10) / 2.55. Formula comes from (its formula seems to use inches, that's why I use a division by 2.55 to get centimeters).
  • There's a voltage peak at about 4 cm: for a given obstacle, you can't know if it stands at less than 4 cm or more than 4 cm. You'll have to keep this in mind for you obstacle avoidance strategy.

As this single output is analogic, you have to wire it to the last available analogic pin of ATtiny85.

Now all components are wired (see next paragraph for wiring schematics), and ATtiny is fully used. Only pin number 1 should remain free. This pin may be used as an ADC ou digital I/O, but if you use it you won't be able to upload programs to the chip (except with an “heavy” treatment to restore its RESET function which is outside of this post).

Schematics and program

Breadboard assembly

Breadboard assembly

Schematics and code are available on GitHub.

Download on GitHub

Just a word about obstacle avoidance strategy, which is pretty simple:

  1. The rover goes forward until an obstacle is below 15 cm.
  2. Then the rover goes backward until the obstacle is at least at 25cm.
  3. Then the rover randomly turn left or right for 2 to 4 seconds
  4. Go to step 1

Some photos

TinyRover core
TinyRover core. On the left, ATtiny85 microcontroller; in the middle, L293D motor driver; on the right, voltage regulator. Have a look to 1 euro coins to get an idea of the scale.

IR proximity sensor
Infrared proximity sensor. You can see noise filtering capacitors badly inserted.

Battery pack
Battery power pack. Really bigger than electronic part.

Go TinyRover, Go !

comments powered by Disqus