Peuchele bio photo


Pedí pollo que yo pago la diferencia!


Tiny Pong VGA push button

As it was suggested by Hackaday’s guys, I’ve added a simple push button in the only available pin of my ATtiny45 in order to control the Tiny Pong VGA. The switch toggles the paddle direction up and down, every time you release it.

I’ve made some little changes in the code, so check it out, you might find something interesting or useful. As always, source code, schematics, etc. freely available for download.


Compared to Tiny Pong 1.0, I just added a push button on PB5 with a 10K ohms resistor as pull-down.

Here is a picture of the circuit on the breadboard.

Tiny Pong VGA on the protoboard
Tiny Pong VGA on the protoboard

And a prototype I made with Fritzing

Tiny Pong VGA - Fritzing
Tiny Pong VGA - Fritzing
VGA pinout
VGA pinout

ATtiny firmware

To use PB5 as an I/O port we need to reprogram the ATtiny fuses with some specific flags. Once you do this, you won’t be able to reprogram it anymore using a regular ISP programmer. If you need to flash another firmware, you will need to reset the fuses using a High Voltage programmer; this one worked fine for me.

AVR GNU toolchain is used for this project, so the code is written in GNU assembler.

In order to build the firmware, I use the following script:

avr-gcc -mmcu=attiny45 -mmcu=attiny45 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT pong.o -MF pong.o.d  -x assembler-with-cpp -Wa,-gdwarf2 -c pong.S tables.S
avr-gcc -mmcu=attiny45 -Wl, pong.o tables.o -o pong.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature pong.elf pong.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex pong.elf pong.eep || exit 0
avr-size -C --mcu=attiny45 pong.elf
rm *.o
rm *.o.d
rm pong.eep
rm pong.elf

And to upload it to the chip (note that I’m using the Arduino with mega-isp) I use the following script

[ -e "/dev/tty.usbserial-A8008VmU" ] && PORT=/dev/tty.usbserial-A8008VmU || PORT=/dev/ttyUSB0
avrdude -F -P $PORT -p attiny45 -c avrisp -b 19200 -U flash:w:pong.hex
# fuses
# WARNING: fuses with PB5 as I/O port
#avrdude -F -P $PORT -p attiny45 -c avrisp -b 19200 -U flash:w:pong.hex -Ulfuse:w:0xce:m -Uhfuse:w:0x5f:m -Uefuse:w:0xff:m

Uncomment the last line to program the fuses.


The source code is almost the same as the first version, but I fixed a few bugs. First, the Bresenham’s algorithm was wrongly implemented, and since I needed it only to calculate the next position of the ball when the angle is 22.5 or 67.5, I realized that was easier to simply increment the X (or Y) coordinate when the ball is at an even position.

Regarding the button reading, it is done during the vertical blanking zone, 60 times per second which gives a pretty good responsiveness – see the chkinput label in the code for more details.

Download Tiny Pong 2.0 Source

Tiny Pong on GitHub