Main Content

Connect4 game on an 8 x 8 pixel matrix with 5050 type LEDs with a built-in WS2812B chip.

Connect Four is a two-player strategy game in which the players take turns dropping colored discs into a vertical grid. The objective of the game is to connect four of one’s own discs of the same color vertically, horizontally, or diagonally before your opponent does.

In one of my previous videos I described a way to make such a game on a TFT touch screen. This time I will explain to you how to make a Connect4 game on an 8 x 8 pixel matrix with 5050 type LEDs with a built-in WS2812B chip.

Also now we have two game modes, player vs player and player vs microcontroller. You can find the original code at: az-delivery, and then this code was reworked by Mr. Küster adding the ability to play against a microcontroller. I also added simple sounds with help of “NewTone” library, so the game now is even more interesting.

Otherwise, the device is very simple to build and contains several components:

- Arduino Nano microcontroller
- 8x8 RGB matrix with WS2812 led chips
- Three buttons,
- and Buzzer

Also for the led matrix I made a dedicated grid on a 3D Printer for a better visual impression. Tracing paper is placed on the grid for light diffusion, and then a protective transparent film.

Let’s see how the game works in reality:

After starting the device, with the left button we select player vs player mode, while with the right button player vs microcontroller. In Player vs. Player, the starting color will be changed with each new game, and in Player vs. Microcontroller, the player always has red and begins the first game. After that, the loser always begins. First we will start a game player against the microcontroller, which is indicated by a continuous higher tone. Player is in red, and start first. At the end, if the microcontroller wins, display shows a smiling figure, and if Player win, then figure is sad.

The next mod is player vs player. This mode is indicated by a continuous lower tone. After one of the players wins, a line is indicated by three short flashes followed by a high-pitched sound, and then the entire screen lights up with the winner’s color.”

Link to article