joystick shield v2.4

Joystick Shield v2.4 SHD_JK2
Introduction:
.The Elecfreaks Joystick Shield features Nokia 5110 LCD and nRF24L01 interfaces. You can easy develop your Joystick games, and even communicate with others over the air with the nRF24L01.

The shield sits on top of your Arduino and turns it into a simple controller. 7 momentary push buttons (4 big buttons + 2 small buttons + joystick select button) and a two-axis thumb joystick give your Arduino functionality on the level of old Nintendo controllers.

Note: If you are using the Joystick Shield with the Nokia 5110 Display you can't use a standard Arduino board as those only supply 50mA on the 3.3V pin which is not enough for what the Nokia 5110 backlight needs. Make sure you use a board that can handle more than 50mA on the 3.3V pin if you are using the Nokia 5110 and want backlight!

Technical Details:
ModelSHD-JK

Quantity

1

Color

White

MaterialSemi-fiberglass board

Features

You can also connect it to other platform by 2.54 mm header.

ApplicationGreat for electronic product DIY lovers


Packing List1 x Module
 Dimensions:3.35 in x 2.13 in x 1.65 in (8.5 cm x 5.4 cm x 4.2 cm)

Weight: 2.29 oz (65 g)

Similar Modules:

This is the Joystick Shield for Arduino Simulated Keyboard And Mouse DG

Description
  • nRF24L01 RF interface
  • Nokia 5110 LCD interface
  • bluetooth interface
  • I2C interface
  • one PS2 toystick
  • working voltage: 3.3V or 5V  eg. STM32

Example of Use:

Materials:
-Shield
-Arduino
-Arduino - USB cable

Wiring Instructions:

 Plug the shield on  the arduino and connect the USB cable from the computer to the arduino 



Sketch Instructions:
      copy/paste and upload this code to your arduino board, and after opening the serial monitor,
      you should see different values printed on a line and refreshed very quickly.
      these are the state of the various buttons present on the joystick shield, as well as the current                  position (x and y value) of the joystick.

     

Zone de texte

// Store the Arduino pin associated with each input // Select button is triggered when joystick is pressed const byte PIN_BUTTON_SELECT = 8; const byte PIN_BUTTON_F = 7; const byte PIN_BUTTON_E = 6; const byte PIN_BUTTON_RIGHT = 3; const byte PIN_BUTTON_UP = 2; const byte PIN_BUTTON_DOWN = 4; const byte PIN_BUTTON_LEFT = 5; const byte PIN_ANALOG_X = 0; const byte PIN_ANALOG_Y = 1; void setup() { Serial.begin(9600); pinMode(PIN_BUTTON_RIGHT, INPUT); digitalWrite(PIN_BUTTON_RIGHT, HIGH); pinMode(PIN_BUTTON_LEFT, INPUT); digitalWrite(PIN_BUTTON_LEFT, HIGH); pinMode(PIN_BUTTON_UP, INPUT); digitalWrite(PIN_BUTTON_UP, HIGH); pinMode(PIN_BUTTON_DOWN, INPUT); digitalWrite(PIN_BUTTON_DOWN, HIGH); pinMode(PIN_BUTTON_SELECT, INPUT); digitalWrite(PIN_BUTTON_SELECT, HIGH); pinMode(PIN_BUTTON_E, INPUT); digitalWrite(PIN_BUTTON_E, HIGH); pinMode(PIN_BUTTON_F, INPUT); digitalWrite(PIN_BUTTON_F, HIGH); } void loop() { Serial.print("U:"); Serial.print(digitalRead(PIN_BUTTON_UP)); Serial.print(" "); Serial.print("R:"); Serial.print(digitalRead(PIN_BUTTON_RIGHT)); Serial.print(" "); Serial.print("D:"); Serial.print(digitalRead(PIN_BUTTON_DOWN)); Serial.print(" "); Serial.print("L:"); Serial.print(digitalRead(PIN_BUTTON_LEFT)); Serial.print(" "); Serial.print("x:"); Serial.print(analogRead(PIN_ANALOG_X)); Serial.print(" "); Serial.print("y:"); Serial.print(analogRead(PIN_ANALOG_Y)); Serial.print(" "); Serial.print("S:"); Serial.print(digitalRead(PIN_BUTTON_SELECT)); Serial.print(" "); Serial.print("F:"); Serial.print(digitalRead(PIN_BUTTON_F)); Serial.print(" "); Serial.print("E:"); Serial.print(digitalRead(PIN_BUTTON_E)); Serial.print(" "); Serial.println(); }


This code shows the direction when you push the buttons
   

Zone de texte

const byte PIN_ANALOG_X = 0; const byte PIN_ANALOG_Y = 1; const int X_THRESHOLD_LOW = 300; const int X_THRESHOLD_HIGH = 380; const int Y_THRESHOLD_LOW = 300; const int Y_THRESHOLD_HIGH = 380; int x_position; int y_position; int x_direction; int y_direction; void setup() { Serial.begin(9600); } void loop () { x_direction = 0; y_direction = 0; x_position = analogRead(PIN_ANALOG_X); y_position = analogRead(PIN_ANALOG_Y); if (x_position > X_THRESHOLD_HIGH) { x_direction = 1; } else if (x_position < X_THRESHOLD_LOW) { x_direction = -1; } if (y_position > Y_THRESHOLD_HIGH) { y_direction = 1; } else if (y_position < Y_THRESHOLD_LOW) { y_direction = -1; } if (x_direction == -1) { if (y_direction == -1) { Serial.println("left-down"); } else if (y_direction == 0) { Serial.println("left"); } else { // y_direction == 1 Serial.println("left-up"); } } else if (x_direction == 0) { if (y_direction == -1) { Serial.println("down"); } else if (y_direction == 0) { Serial.println("centered"); } else { // y_direction == 1 Serial.println("up"); } } else { // x_direction == 1 if (y_direction == -1) { Serial.println("right-down"); } else if (y_direction == 0) { Serial.println("right"); } else { // y_direction == 1 Serial.println("right-up"); } } }

   

Resources & Related Links:

Author: Géraud Moustial

Please feel free to leave any comments or questions you may have about this module.
Comments