Learn to park a car with this fun AVR game

Students Lu Liu and Xu Chen from Cornell ECE4760 class have built nice game where you have to park a car on computer screen. They have built steering wheel equipped with accelerometers to detect angle. Also they made accelerator and brake out of hinges with potentiometers as sensors. To make it complete they also made wooden gear shift.


The heart of project is ATmega1284 microcontroller which reads sensor inputs and draws car model on TV screen. Program functionality include user configurable stage selection, status report when finished, car hit detection.

Expanding Attiny microcontroller with shift register

Attiny microcontrollers have small footprint leading to smaller number of I/Os available. These microcontrollers are meant to control simple things like reading sensors, driving relays and so on. If you come to the point where you need more I/O pins then there are two options – use bigger microcontroller or expand number of pins with port expanders or with simple shift registers. For smaller microcontrollers port expanders may be too costly solution, because of limited memory it may require to much of driving like I2C or SPI expanders. In this case better solution is to use shift registers that can be driven pretty easily with not much overhead code and you can get as many pins as you want by connecting them in cascades.


silentbogo wrote a simple instructable on how to interface shift register to Attiny microcontroller (same apply to other micros like PIC12). Register of choice here is standard 74HC595 which is cheap and available everywhere. Depending on what level control you want, there can be various control scenarios. You may want to have master reset(MR) or output enable(OE) functionality. But for basic operations and to save I/Os these pins are connected to VCC or GND. To reset register there can be 0x00 data shifted in. In this case only three pins are needed DS, SHCP and STCP what stands for data in, latching and clocking. By using smart solutions you will find that using larger microcontroller is not always best option.

Getting started with ATTiny13

Not all microcontroller projects have to be large. In many cases you need to do very specific tasks where you only need couple I/Os and small routine. For such things you can find tiny microcontrollers that come with small footprint. A good example is ATTiny13 microcontroller that are cheap but effective in many tasks. ATTiny13 comes with 1KB of flash and 64B of RAM. If you are used to work with larger micros (eg. Arduino), in some cases it might be a bit challenging to write effective code. Xplo1t shares his experience on this small micro. He points out few benefits of choosing ATTiny microcontrollers over Arduino. First of all it’s price, then versatility and small size. With small size there comes energy efficiency.


He has build a small demo board which comes with single LED along with current limiting resistor and reset button with resistor pull-up. In order to program microcontroller you will need ISP programmer. If you have spare Arduino it can serve this purpose. With such small memory amounts Xplo1t goes with assembler code. Atmel Studio comes with AVRASM2 binaries. Programming assembly language is quite time consuming but in other hand you get to know how microcontrollers work and thus write more efficient code in C keeping inner structure in mind. There are other things that you will have to deal including fuse settings and flashing with Avrdude – command line tool. If you learning micros, this is worth trying.

Implementing rock-paper-scissors-spock-lizard game with gesture recognition

Rock-paper-scissors-spock-lizard game is quite popular game which is more complex than rock-paper-scissors. There are five gestures used instead of two. Each gesture can beat two other and two remaining gesture can bet the particular one. Students from Cornel ECE 4760 class decided to push this game to new limits – make computer to recognize gestures and play along.


They used OV7670 digital camera with Atmega1284 microcontroller which captures images and sends them to Matlab for faster processing. Feedback is displayed on VGA screen. So the hardware mainly deals with getting images, sending them to PS via USART and displaying results on screen. It takes two AVR microcontrollers to do that. The limitation here is sending images to Matlab for processing, because of serial port limitations. They used run-length coding to improve transmission. Matlab does the heavy load on recognizing gestures by scanning pixel changes. Algorithm isn’t very efficient and not immune to noise, but works.