Reply to topic  [ 1 post ] 
Analogue Joystick Controller (HCARDU0019) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 713
Post Analogue Joystick Controller (HCARDU0019)


PS2 style 2 axis directional joystick, which is compatible with the Arduino interface. Product code for this item is HCARDU0019 and it can be purchased here.


3..............X-Axis (analogue)
4..............Y-Axis (analogue)
5..............Push button (Connects to GND)


#define JOYS_VRX_DIO A0    /* Selects the input pin for the joysticks X-Axis */
#define JOYS_VRY_DIO A1    /* Selects the input pin for the joysticks Y-Axis */

#define JOYS_SW_DIO 2      /* Selects the input pin for the joysticks push button */

/* Initialises serial and DIO */
void setup()
  /* Sets up the serial port for displaying the status of the sensor */
  /* Configures the DIO pin that the joysticks push button will be connected
     to. As it has no pull-up we will need to enable the Arduino's internal pull-up */
  pinMode(JOYS_SW_DIO, INPUT);
  digitalWrite(JOYS_SW_DIO, HIGH); // turns on pull-up resistors

/* Main program loop */
void loop()
  /* Reads the current position of the joysticks X & Y axis via the analogue pins */
  Serial.print("X axis: ");
  Serial.print("  Y axis: ");
  /* Reads the state of the push button and if pressed, outputs the state to the
     serial port */
  if (!digitalRead(JOYS_SW_DIO))
    Serial.println("  Button pressed !");

Wed Mar 02, 2016 11:20 am
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to &
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD