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.
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 …
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 …
Want to store your Arduino project’s data, measurement’s or sensor readings for future analysis? Then you are in the right place, cause today I’m gonna list here the best 5 Arduino Data logger Modules. Data logger gives you the ability to track your system statistically and check how it worked over certain intervals . You can also …
Ever wanted to talk to your Arduino project? Recently I watched this video of a Harry Potter magic wand that you can command to turn on lights and order food! Disclaimer: I’m not a Harry Potter fan, not a fan of Star Trek or Star Wars either! Total Game of Thrones nerd though, check out …
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 …
Making a tracking system is something that most of us wanted to have in our projects, and with all that modern technology offering us, it can be made very simply with our beloved board “Arduino” and a GPS shield. Today I will make a detailed comparison between our 1Sheeld GPS shield and the SparkFun GPS …