Most of us used to play video games using joystick either on PlayStation or PC. When I started tinkering with Arduino, when I built a robot or a vehicle, I also wanted to control it with a similar joystick, so I got the Sparkfun joystick shield.
Today I will make a detailed comparison between our 1Sheeld gamepad shield and the SparkFun joystick shield, I will take you in a step by step tutorial till we can control 4 LEDs lightening to indicate the direction of the joystick. Let’s get started!
1- SparkFun Joystick Shield
The first shield we are going to cover is the SparkFun joystick shield. It is a nice shield which gives you the feeling of the old Atari Joystick, you can get it directly from SparkFun website, it comes with the whole package of Joystick and pushbuttons withR3 stackable headers but it’s all unsoldered and you have to solder it yourself.
The joystick internally consists of two potentiometers, one of them measures the vertical resistance and the other measure the horizontal one, they are connected to both pins A0 and A1 and a small push button under it is connected to pin 2.
Regarding the other push buttons, the smaller one is the shield reset button and the other 4 push buttons are action button connected to pins 3, 4, 5 and 6.
Now let’s go to the step by step tutorial.
Step 1: Adjust the shield
As I said that the shield is not pre-assembled so we have to solder the joystick and the headers into it, so we have to get a soldering iron and solder like this.
Actually, SparkFun is providing a very simple Assembly guide especially for this shield.
The first thing to be soldered is the joystick and the push buttons but be careful while soldering the joystick cause it has so many pins.
Then solder the headers to it.
Voila!! That’s how it supposed to be like after soldering the pin headers.
Step 2: Mount the shield on the Arduino board
The shield can be mounted over the Arduino board but there are two drawbacks in it, the first thing is that in Arduino UNO case which am using the shield is hitting the USB interface of the Arduino board where if I forced the shield to completely mounted on the board the shield may be broken or I may harm the USB interface so please be careful.
The other thing is that mounting another shield over the joystick shield is impossible, understandably because you need to use the buttons on it, so if you are using multiple shields, you have to keep that on the top.
Step 3: Write the code
In this example I will control 4 LEDs depending on the direction I pressed on whether using the joystick or the normal pushbutton and when am using the joystick I can turn two LEDs at the same time if it lays in between two different directions like the “up right”,“up left” and so on
// Store the Arduino pin associated with each input
// Specify each pin connected to a pushbutton as an input.
// Also enable the Arduino's internal "pull-up" resistors
// for each pushbutton we want to read--this means the shield
// doesn't need to have resistors on it.
// Note that when a pull-up resistor is used on a pin the
// meaning of the values read are reversed compared to their
// usual meanings:
// * HIGH = the button is not pressed
// * LOW = the button is pressed
// y_direction == 1
// y_direction == 1
// x_direction == 1
// y_direction == 1
Step 4: Build the hardware
I have connected 4 LEDs of 4 different colors on pins(9, 10, 11 and 12) to indicate the direction I pressed.
At the end of this tutorial, I want to say that using this good looking shield gives you the feeling of the old Atari games feeling but actually with some bad user experience cause you should hold the whole system in your hand with all the cables, wires and even batteries, and when you use it for a long time you will feel the heat coming from the system due to long use.
2- 1Sheeld Gamepad Shield
Now it’s time to show our awesome 1Sheeld gamepad shield.
For anyone who does not know about 1Sheeld, it is a board that connects your smartphone’s sensors and peripherals to the Arduino, allowing your smartphone to control Arduino and Arduino to control anything on your phone.
The most important thing in 1Sheeld is that you can make a lot of amazing things with only 1 line of code!
So, here we are going to control 4 LEDS lightening using a gamepad on your smartphone which will give you the feeling of mobile app games controlling.
You will find two versions of it the 1Sheeld for Android phones and the 1Sheeld+ for iOS and Android phones from 4.3 and above.
Now let’s get started with the 1Sheeld!
Step 1: Adjust 1Sheeld
Warning! If you have an Arduino that works on 3.3V then you must make your 1Sheeld to work on the 3.3V mode since it may damage your board.
Step 2: Mount the 1Sheeld over the Arduino board
In my case am using Arduino UNO board if you have a different board you can check how to mount 1Sheeld to different Arduino board from this tutorial.
Step 3: Install Arduino library
Download the 1Sheeld library from here and after unzipping it, copy the folder to your libraries directory or you can manage any libraries from Arduino’s IDE .. just click Sketch >> Include library >> Manage libraries >> type “The library name” >> then click install and you are good to go.
This code simply is controlling the 4LEDs lightening with the Arrows and the buttons of the shield, each LED is representing one of these directions ( Up, Down, Right and Left) so i combine each two corresponding arrow and button to control each LED.
After writing the code, make sure to set 1Sheeld UART switch to the uploading mode before you upload your code to Arduino.
After uploading the code, the 1Sheeld is not ready to work until you switch it back to the operating mode.
Operating mode is turned on when the UART switch is pushed towards 1Sheeld logo.
Step 6: Use the 1Sheeld application
Open 1Sheeld application on your Android phone or iOS device.
The application will first scan over Bluetooth for your 1Sheeld, it will take a few seconds and the phone will find it.
Once it appears on your screen as 1Sheeld #xxxx, you will be required to enter the pairing code (the default pairing code is 1234) and connect to 1Sheeld via bluetooth.
Step 7: Access the shield
Select the shields you would like to use in your Arduino sketch and press on the multiple shields icon at the top right of the app.
In this case, use Gamepad shield.
As you see in the above image it has 4 arrows and 4 colored buttons which gives you the ability to make lots of applications, and thanks to our open source community, one of our Github repo contributors Mustafa Shaarawi developed the gamepad shield arrows to be an analog joystick, he finished the mobile app and the Arduino library and now it’s under testing so stay tuned for our coming release! Here is an image for the shield and how it will be displayed.
There will be two options which are the arrows mode and the joystick mode, just press the mode button and it will toggle to the other state.
Adding motion as an input for your project is going to be so much fun! You can do this by using an Accelerometer Module that measures acceleration in three linear axes (X, Y, Z) and then you can translate it into actions. Today, our topic is all about Arduino Accelerometer projects. In fact, Arduino Accelerometer …
Whenever it’s time to get off the office, I always check the traffic status to choose the best time to go home. But I couldn’t find a way to do that autonomously. So then …. I was up to make a system that shows me the current traffic status with the help of a simple tool that is used …
The newer version of 1Sheeld (1Sheeld+) built to support both iOS and Android devices,but not just that …! There’s another secret feature supported to solve the problem of using extra shield/board over 1Sheeld+, and this shield/board have the same way of communication used by 1Sheeld+ (The hardware UART serial pins pin0&pin1) with your Arduino. Exactly …
Nowadays people started integrating stuff with the internet for their daily uses, and fortunately, it’s not hard to do so..! as there are a lot of hardware/software tools that ease the development of such applications. One of these tools is the 1Sheeld’s Internet shield, which allows your arduino board to connect to a mobile application …
It’s now the age were the word “Hack” is a relevant word we see and hear everywhere, and i don’t mean the software cyber hacks,I am talking about DIY hacks 😀 . We made this Home Automation Hacks series to help you add fun features to your home stuff by doing it yourself 😉 . …
Welcome to our home automation hacks series #2, today I am going to show you how to hack your home outlets with Arduino and a phone gesture 😉 .This time I used Accelerometer sensor shield from 1Sheeld application. And with a simple gesture it will open\close the outlet to trigger the fan on or off …