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.
And a prototype I made with Fritzing
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:
And to upload it to the chip (note that I’m using the Arduino with mega-isp) I use the following script
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.