And we’re back with another DIY gaming project! As always, playing with something made with your own hands is always an out-of-the-world experience! First, it was a DIY Game Controller; now it’s time for a DIY Joystick using Accelerometer!
This time we’re going to make a DIY Joystick using an accelerometer using which you can control a robotic arm, an entire robot, and even play many games!
Ready to transform your gaming experience? Then begin right away!
|Image||Component||Quantity||Available in Kit|
|Male to Male Jumper Cable 20cm||Few|
Step 1: Assembly
We have interfaced the accelerometer with our 2 previously made robots. Whose assembly you can find on the link given below.
And will also use as:
- A Game Controller
The catch here is that we will be using the accelerometer to control the movements of robots or the game sprite.
With this, we have completed our assembly part.
Step 2: What is Accelerometer?
What is the Accelerometer:
An Accelerometer is a device used to measure the acceleration, which is nothing but the change in velocity with respect to time. To be precise, the accelerometer we use here measures the change in the gravitational acceleration.
Working of Accelerometer:
There are many ways in which an accelerometer works. But, the major ones are the piezoelectric effect and the capacitive effect.
The piezoelectric effect is the most popular one. In this technique, there is a microscopic crystal which is stressed due to the presence of accelerative forces. The charge is then accumulated on the crystal which is then amplified or turned into output voltage or current.
The capacitive accelerometer senses the change in the capacitance between two microstructures which in turn changes to the output voltage.
Step 3: Logic
As we know, our sensor can respond in specific values to any tilt or movement in its x, y, or z-axes. We will be using this property and will assign specific actions for each change.
- In Mobile Robot:
- Tilt Forward – Robot moves Forward
- Tilt Backward – Robot moves in Reverse Direction
- Tilt Right – Robot turns Right
- Tilt Left – Robot turns Left
- No Tilt – Brake
- In Robotic Arm:
- Tilt Forward – Base Servo will turn Left
- Tilt Backward – Base Servo will turn Right
- Tilt Right – Link Servo will turn Right
- Tilt Left – Link Servo will turn Left
- No Tilt – Stop
- As Game Controller
- Tilt Forward – Jump / Space
- Tilt Backward – Shoot / Shift
- Tilt Right – Game Sprite will move Forward
- Tilt Left – Game Sprite will move Backward
- No Tilt – Stop
Step 4: Circuit Diagram
Step 5: Code
The following code should be followed for driving the Mobile Robot. Robotic Arm
To control the Robotic Arm with the accelerometer, we should write the following code. Game Controller.
Here we will be using Processing along with Arduino.
Once the key is pressed, Arduino assigns the number to it according to the code.
We use processing as the interface between Arduino and the PC.
Arduino then sends the signal number to Processing.
Eg., when we press UP key. Arduino sends ‘1.’ to Processing. Processing performs the action that it corresponds too.
The Arduino code is as below: The Processing code can be downloaded from the code section below:
Step 6: Conclusion:
With this, your DIY Joystick using accelerometer is ready! Now you can have double the fun playing your favorite games!
The following connection should be made for driving the Mobile Robot.
To control the Robotic Arm with the accelerometer, we should connect as follows.
Connection to be made to use as a Game Controller.
|Arduino Code for Mobile Robot||Download|
|Arduino Code for Robotic Arm||Download|
|Arduino Code for Game Controller||Download|
|Processing Code for Game Controller||Download|
DIY Automatic Railway Crossing
This project will show you how to make a DIY automatic railway crossing.
DIY Smart Trash Bin
This project will show you how to make a DIY Smart Trash Bin.
DIY Unique Christmas Tree
This project will show you how to make a unique DIY Christmas Tree for this year’s Christmas.