Arduino MPU6050 Interactive scrolling game on 32x8 Led Matrix

0 20931 Medium

   This time I will show you how to make an interesting interactive game, on a 32 by 8 LED matrix, which is controlled by moving the device. During a certain movement of the device, the MPU6050 sensor sends a signal to the microcontroller, and based on that information, the microcontroller performs a given action on the screen. 

   In fact, the sensor represents a so-called air controller that we can find as part of remote controls for modern TVs. The project is featured on Benjamin Balogh's GiHub page (https://github.com/benibalogh/LEDMatrix-Games), where you can find the original code. The source code is made in Visual Studio with support for Arduino, known as Visual Micro.
  Unfortunately, after compiling and uploading the original code to the Arduino, the device did not process data from MPU6050, and only scrolled the text "Wall Scroller". I tried to contact the author several times, but without success. After certain time of studying the code, with one small modification, I managed to adapt it. Also, instead of Visual Micro, I compiled it into a standard Arduino IDE.


 To compile the code without errors, you should open the code from the given folder that contains all the required libraries. Let me emphasize that if you have previously installed any of these libraries in the Arduino IDE, you should delete them. I also added some simple tones to the code that don't interfere with gameplay and make the game much more interesting


  The device is extremely simple to build and consists of only few components:

1 Arduino Nano
1 DFRobot 6 DOF Sensor - MPU6050
1 8x32 Led Matrix Module MAX7219
1 Buzzer
1 Pushbutton Switch, Momentary
1 Through Hole Resistor, 56 ohm

  If you want to make a PCB for this project, or for any other electronic project, PCBway is a great choice for you. PCBway is one of the most experienced PCB manufacturing company in China in field of PCB prototype and fabrication. They have a large online community where you can find a Open Source projects, and you can also share your project there. From my personal experience I can tell you that on this community you can find many useful projects with alredy designed PCBs, from where you can place an order directly.


  After uploading the code, we need to make some settings. Depending on the mounting position of the sensor, we need to perform a calibration by changing the values in the following lines of code 
  constexpr float INIT_PITCH = radians(175.0f);
  constexpr float MENU_BACK_ROLL = radians(-90.0f); 
  constexpr float MENU_ENTER_ROLL = radians(-155.0f) 
  constexpr auto TILT_ANGLE = 145;
  constexpr float MENU_NAVIGATION_PITCH = radians(TILT_ANGLE + 30);
 Angles can have positive and negative values
   Immediately after switching on, a scrolling text with the name of the game appears. By tilting to the left we move through the menu. To activate an option, we tilt the device down. We return to the menu by tilting the device upwards. To start playing the game, when we are in the PLAY menu, we tilt the device down and then to the left. Now we play the game by moving left and right, trying not to hit the wall. With each passed segment, a certain number of points are obtained. After a certain time, the movement speed increases. When we collide into the wall, the end of the game is signaled and the result appears. By tilting up, we return to the main menu again.
 Let me mention that the power supply is made with a 3.7V Lithium battery, a charger board for charging the battery, and a boost module that raises the voltage from 3.7V to 5V. The schematic diagram for the power supply is given in the figure below.


  Finally, the device is installed in a suitable case made of PVC board and covered with colored wallpaper.

icon Wall Scroller CODE FINAL with Sound.zip 72KB Download(0)
All Rights