Arduino Flappy Bird Dot Matrix Project
Start your DIY gaming experience with this "Arduino Flappy Bird Project with Dot Matrix." This project merges the timeless appeal of Flappy Bird with the dynamic capabilities of Arduino and a Dot Matrix display. This article includes hardware setup, gameplay mechanics, and of course, the source code.
This project is a simple clone of the popular Flappy Bird game. The original app isn't available in the app store anymore, although there are a lot of clones. Here is the original:
The objective of the game, for those who are unfamiliar, is to control the bird as it avoids “pipes”. The amusing part is that the bird jumps in the air with every push of the button and falls when left unattended, making it harder to avoid the pipes.
This is a good starting project for those who want to dive into game design. You’ll be familiar with two-dimensional coordinates, randomization, and button handling.
ChatGPT suggested the idea for this game. Then I tried googling for any similar project that uses a dot matrix. To my surprise, there was none so that affirmed my decision to make one.
Bill of Materials
Any Arduino board with an ATMega microcontroller can be used in this project. The dot matrix orientation is such that the DIN pin is on top. A buzzer or piezo speaker can be optionally added for simple game sounds.
|Dot Matrix (MAX7219)
The main screen is a simple marquee of the text “Arduino Flappy Bird”. The game starts when the user presses the button. The “bird” starts in the middle and traverses left to right. Obstacles or pipes appear in its path with the passage location randomly generated. The player scores a point every time the bird passes a pipe. Thus, the player must press the button correctly to avoid a pipe. The game is over if the bird hits a pipe or the ground.
Each frame takes 1 second to execute. As one frame passes, so does one movement of the bird and the pipe. The bird may move up two pixels when the button is pressed or down until the button is pressed. Similarly, the pipe moves 1-pixel position from right to left.
The button press serves as an external interrupt. In the interrupt service routine, a flag is either set or clear depending on the current state of the bird. If the bird is falling, then the flag is set, indicating that the bird is now rising. When the bird is already rising, the flag clears to indicate the bird is falling. This flag is continuously checked inside the loop to create the appropriate bird movement.
The full code can be downloaded from this repository.