Something that was bothering me for some time now is that I haven’t made anything fun in a while, mainly because I lack good ideas for things like that. Luckily, an idea came to my mind to do this project out of nowhere, and viola, here we are.
Now, just to point out, this project was NOT written in Arduino, rathte pure AVR C code using Atmel Studio. I am using an Arduino Uno and an Uno-compatible shield, but mainly because that is the cheapest and most available thing I have with me (same goes for the keypad shield I have it for years now). So for anyone familiar with C but only worked in Arduino, about half of the code would look confusing here, but take it from someone who took to learn AVR C (by myself), it’s not hard at all as I managed to adapt to it in a week (more less).
If you want to use the code or just flash the firmware on the UNO board, I recommend watching this video.
For the most part, I’ve explained everything in the code itself, here I’m going to more explain the working principle of the code.
Hitachi HD44780 (LCD Driver) and Its 4-Bit mode
This was a bit of a struggle for a datasheet newbie, but interfacing with this IC was pretty frustrating. I ended up copying configuration bytes from this guy (thanks dude). Everything else depends on setting the bits in the upper 4 pins of the PORTD register and using EN and RS pins properly. In my implementation the whole PORTD is wasted for communicating with the display (thus nullifying the benefits of the 4-bit mode) and effectively wasting the UART but I wasn’t going to use those for anything else anyway so it’s ok for this use case. Make sure when you interface with this IC to use proper delays otherwise it won’t be able to process the data properly (it is a fairly slow chip). Another point is that the game speed is limited by how quick the display can refresh. At its highest peek speed, the display updates at 11.8Hz (85ms delay on loop) and it’s readable enough to play this kind of game, everything further causes major gosting and brightness issues. Now, you have to keep in mind, this doesn’t want the IC and display are made for, just simple text displaying.
To read more, please click here!
Additional products to consider...
Like this article? Click here to recieve the lastest news direct to your inbox