GamePad using Android mobile sensors and Arduino

Today, I will introduce to you how to use your Android mobile or tablet to play computer games using the sensors of the mobile and buttons.

Actually, I always dreamed to play some mobile games as Asphalt, using a much bigger screen than the mobile or tablet screen.

The idea of playing games using the motion of the body based on sensors of the mobile phone is awesome!!!. The project is so easy and doesn't require any experience android programming, it's only a 2 steps project.

Step 1: Components

GamePad using Android mobile sensors and Arduino

1- Arduino Leonardo (25$)
(or any Arduino support the keyboard library on Arduino IDE).

2- 1Sheeld (60$)

3- Android Smart Phone/ Tablet.

(Note: These images taken from 1Sheeld website)

Step 2: Android Application

GamePad using Android mobile sensors and Arduino

Basically, All you have to do here is to download 1Sheeld application from play store. This Application gets rid of a hell of a headache for developing the Android Application.


Step 3: Arduino Sketch

GamePad using Android mobile sensors and Arduino

Back to our project, all we need from the mobile phone is its rotation to change direction and pressing one of 2 buttons to check whether forward or backward. To get the orientation of the mobile you can use either the gyro sensor or the gravity sensor. Yet, I used the gravity since I found it more stable in the readings or you can use as well the Orientation shield in the application which is based on gyro. We will use the Keyboard Library of Arduino to take the action as if it is the real keyboard, so that's the reason we need Arduino Leonardo or any one support this library.

From the Keyboard Library, you have got that:





Here you can find the code.

#include void setup() { OneSheeld.begin(); Serial.begin(9600); Keyboard.begin(); } void loop() { if (GamePad.isUpPressed()) {;} else {Keyboard.release(0xDA);} if(GamePad.isDownPressed()) {;} else {Keyboard.release(0xD9);} if (GravitySensor.getY() 1) {;} else {Keyboard.release(0xD7);} }

Step 4: Attachments

GamePad using Android mobile sensors and Arduino

After Uploading the sketch to the Arduino. Attach the 1Sheeld over the Arduino and connect both to the computer.

Step 5: Have Fun

GamePad using Android mobile sensors and Arduino
GamePad using Android mobile sensors and Arduino

Now, open your Mobile Application, you have to pair the 1Sheeld with the mobile using Bluetooth. Then choose the Gravity shield and the Game pad shield from the application and then click next.

Now you can move the car using the upper and lower bottoms and by rotating the mobile you can change direction of the car left or right.


Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel