If you are not familiar with Conway's Game of Life, there are millions of web pages which tell you about. For this so-called game, in theory you need a board of infinite size which does not exist. But the more elements your board has the better. Unfortunately, Conway's rules don't tell you what should happen when neighbouring cells are located outside the border of your board. So, if a glider for instance approaches the border it will turn into a stabil square of 2x2 elements and rest there until eventually hit by another object.
Update 22. June 2025: added one initial configuration and ARDUINO DUE as target board.
Some preliminary considerations for how to present the boardUsing the 12x8 LED matrix of the UNO R4 WiFi you have no fun, neither with the 5x5 matrix of the micro:bit or the Calliope. The smallest TFT display I got is the ST7735S 1.8 inch with 160 x 128 pixels.
Schematics - the hardwareThe schematics is straight forward; see Adafruit instructions how to connect pins 8 to 13 to the display. As there are no shields available I designed my own one.
At first you have to do the math: programming this game, you need to store the states of all pixels, giving 20480 pixels. Even if you store eight bits in one byte you still need 2560 bytes which a standard UNO R3 does not have. Further more, if you were displaying the elements so dense it would be hard to see them properly. So I decided to show a square of 2 x2 pixels to represent one element, and have a distance of one pixel to the next square. That leads to following calculation:
width: 160 / (2 + 1) = 53.3
height: 128 / (2 + 1) = 42.6
This still needs 53 x 42 = 2226 locations to store, but when you store eight bits in one byte, you only need 279 bytes. Actually, you need a little more, because Conway's rules tell you to calculate the new generation on base of the previous one, and you must not overwrite and destroy the previous one as long as you still need it. The problem is that access to a certain bit in byte can be very time-consuming, so you need to find a way to circumvent this. See second attachment.
If you want to see the maximum resolution just download the last attachment. And don't forget to grap a good looking glass.
Once you have finished it all you want to test your code with some more or less well-know patterns. I decided to select them by using jumpers connected to the pins A0... A5.
When using the ARDUINO DUE, please note that the SPI pins are not at pin-11 and 13. You easily find them at the 6-pin SPI connector. As the DUE is a 3.3 volts type you do not need any level shifters.
My TFT libraryAs calculating that many cells takes a lot of time, I wanted to use one of the still new ARDUINO UNO R4 boards. The problem was, the standard library <TFT.h> does not work for the R4. So I sat down and wrote my own one which works for both R3 and R4 (see first attachment). Guess on which of the boards the game runs faster? Anyway, as the R4 has much more memory the code can be simplified a lot as you do not have to compress bits in bytes. Compare with the third attachment.
Some screenshots show what is possible:

_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)





Comments