Level Pong
A level pong game.
Balls will drop from the top and you will need to catch them on the small bar at the bottom of the display. You can move the bottom bar left and right by changing the pitch angle of the MPU-6050 sensor. This game can be easily played straight from the humble breadboard without making any enclosed for it. This is why instead of making an enclosure and hiding away the beautiful electrical components I have assembled the whole thing on a simple breadboard PCB.
This game uses an Inertial measurement unit (IMU) to determine the pitch angle. For better understanding of the MPU-6050, I highly recommend this video by DroneBot workshop: https://dronebotworkshop.com/mpu-6050-level/
I have tested this game with Arduino Uno and nano but any microcontroller with I2C communication should work. If you want to pack it in a small enclosure, the Adafruit trinket can also be a suitable choice.
Supplies
One MUP-6050
One Arduino Nano or Uno or any other microcontroller with I2C communication
One Adafruit 8x8 LED matrix with soldered to its backpack
One Push button
10 male-to-male jumper wires
Wiring
Wire the components according to the connections shown in this picture
Wire the ground from the Arduino Nano to the breadboard's negative rail
Wire the Nano's 5V to the breadboard's positive rail
Connect the display's negative terminal, MUP-6050's GND, and one leg of the push button to the breadboard's ground rail
Connect the display's positive terminal, and MPU-6050's positive terminal to the breadboard's positive rail
Connect the A4 pin on Nano to the SDA pin on both display and the MPU-6050
Connect the A5 pin on Nano to the SCL pin on both display and the MPU-6050
Connect another leg of the push button to the Nano's D2
If the push button has four legs and you are not sure which legs are internally connected, then use the leg diagonally opposite to the leg you connected to the ground. I saw this awesome trick from this video: https://www.youtube.com/watch?v=iv3PvUbZjoA
Upload the Code and Play
Now the wiring is nicely done, upload the attached code to your microcontroller and enjoy playing the game. I hope you like it. If you want to change how fast the balls drop you should modify the code mentioned as game_difficulty. I have tried my best to put comments in the code but if there is something you don't get leave just a comment and I will try to explain what it is and why.
Downloads
Wanna Attach Another Display?
Just in case you also want to attach an OLED display to this game, here is the wiring diagram and code for it. The code is not well commented and variables are named oddly but it should get you started. Have fun making.