XY-axis Joystick Module (KY-023) [S056]



https://www.youtube.com/watch?v=hFNXbU8lUQo


*GitHub https://github.com/rdiot/rdiot-s056.git



* Specs

The company produces PS2 game joystick axis sensor module consists of using original quality metal PS2 joystick potentiometer system For the (X, Y) a 2-axis analog output and for (Z) 1 digital output channel button.


* Contents

- Connect

GND ----- GND

5V ----- 5V

X-axis ----- A0

Y-axis ----- A1

SW(Swtich) ----- D2


- Key Code


#include <Wire.h> 

#include <LiquidCrystal_I2C.h>

 

LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004

 

int X = A0; // x

int Y = A1; // y

int S = 2; // SW

 

void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");

 

  pinMode(X, INPUT);

  pinMode(Y, INPUT);

  pinMode(S, INPUT);

  digitalWrite(S, HIGH); 

 

  delay(1000);

 

  lcd.clear();

}

 

void loop()

{

 

  lcd.setCursor(0,0);

  lcd.print("S056:XY-axis Joystick");

 

  int x, y, s; 

  x = analogRead(X);

  y = analogRead(Y);

  s = digitalRead(S);

 

  lcd.setCursor(0,1);

  lcd.print("X=" + (String)x + "   ");

 

  lcd.setCursor(0,2);

  lcd.print("Y=" + (String)y + "   ");

 

  lcd.setCursor(0,3);

  lcd.print("SW=" + (String)s + "  ");

 

  delay(100);

}

'2) Sensor > Joystick' 카테고리의 다른 글

Classic Arcade Joystick Red Ball 4/8 Way [S207]  (0) 2016.09.12
Posted by RDIoT
|