RASPBERRY PI AND ACCELEROMTER MXC6226XU AS GAMING CONSOLE
by Qatalytic Technologies in Circuits > Electronics
862 Views, 9 Favorites, 0 Comments
RASPBERRY PI AND ACCELEROMTER MXC6226XU AS GAMING CONSOLE
![sixith.jpg](/proxy/?url=https://content.instructables.com/F2H/WU2O/IJBTYE35/F2HWU2OIJBTYE35.jpg&filename=sixith.jpg)
The tutorial below shows how to use accelerometer sensor and raspberry pi as gaming console.
The M6226XU Digital Thermal Orientation Sensor (DTOS) is the world's first fully-integrated orientation sensor. Its operation is based on a patented MEMS-thermal technology and is built using a standard 0.18um CMOS process.
MXC6226XU is specified for use in LCD TVs, toys, MP3/MP4 players, fan heaters, halogen lamps, and irons.
This projects demonstrates a version of space invaders where the flying shot is controlled by tilting the accelerometer sensor. The code for the same can be found here.
ACCELEROMTER sensors as a joystick
Hardware Required : Raspberry pi , I2C adapter , MXC6226XU board and an I2C cable
( You can find the I2C adapter , MXC6226XU board and I2C cable at www.controleverything.com)
https://www.controleverything.com/content/I2C-Master?sku=TOUTPI2
https://www.controleverything.com/content/Accelorometer?sku=MXC6226XU_I2CS
https://www.controleverything.com/content/I2C-Cables?sku=I2CAFF12
Make Connections
![IMG_20160113_132935828.jpg](/proxy/?url=https://content.instructables.com/FWA/5570/IJBTYELX/FWA5570IJBTYELX.jpg&filename=IMG_20160113_132935828.jpg)
![first.jpg](/proxy/?url=https://content.instructables.com/F1T/B6JO/IJBTYE31/F1TB6JOIJBTYE31.jpg&filename=first.jpg)
Connect I2C adapter over GPIO pins on Raspberry pi and press it.
As it gets fixed connect a I2C cable with I2C adapter and MXC6226XU bo
Power Up Pi and Run Code
![third.jpg](/proxy/?url=https://content.instructables.com/FT9/OMNO/IJBTYE3D/FT9OMNOIJBTYE3D.jpg&filename=third.jpg)
![fourth.jpg](/proxy/?url=https://content.instructables.com/F5M/NZV2/IJBTYE32/F5MNZV2IJBTYE32.jpg&filename=fourth.jpg)
![second.jpg](/proxy/?url=https://content.instructables.com/F6G/PJVO/IJBTYE34/F6GPJVOIJBTYE34.jpg&filename=second.jpg)
Power up the pi once the connections are done. Type command " startx " to switch on the pi in graphical mode.
Download the code from github and copy to pi.
Create a class for the sensor code. The java code used pi4j library. Its a java library for I2C and GPIO created for pi. Instructions to install library are in the comments of the code.
Run the code as :
pi4j Game
Instructions to run the code are in comments of the code.
" Start Playing "
![GAME.jpg](/proxy/?url=https://content.instructables.com/FEE/UUVI/IJBTYFHE/FEEUUVIIJBTYFHE.jpg&filename=GAME.jpg)
![Raspberry pi and Accelerometer sensor as a gaming console](/proxy/?url=https://content.instructables.com/FW8/292V/IJBTYE39/FW8292VIJBTYE39.jpg&filename=Raspberry pi and Accelerometer sensor as a gaming console)
You can now see the game space invaders running. Press any key to start.
Hold the accelerometer in a horizontal plane. The shot fired from spaceship will move to left or right as you tilt the sensor to left or right.
You can also refer to youtube video here.