GamePad using Android mobile sensors and Arduino

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: 

KEY_UP_ARROW 0xDA 218

KEY_DOWN_ARROW 0xD9 217

KEY_LEFT_ARROW 0xD8 216

KEY_RIGHT_ARROW 0xD7 215

Here you will find the code. 

After Uploading the code, 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.




Related Blogs

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …

Arduino IoT

Arduino IoT Shield Functions Explainer

Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …