'2) Sensor/Joystick'에 해당되는 글 2건

  1. 2016.09.12 Classic Arcade Joystick Red Ball 4/8 Way [S207]
  2. 2016.09.12 XY-axis Joystick Module (KY-023) [S056]

Classic Arcade Joystick Red Ball 4/8 Way [S207]




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


*GitHubhttps://github.com/rdiot/rdiot-s207.git



* Specs

Color: Red

Top Ball Diameter: Approx. 35mm

Total Size: Approx. 95x60x100mm


Features

Brand new and high quality.

8 way operation.

Fits metal control panels.

Easy to operate, with high sensitivity.

You can use it to DIY your own Arcade game machine.



* Contents

8 Way Basic Test


- Connect

TOP ----> D2 // UP

BOTTOM ---> D3 // DOWN

RIGHT ---> D4 // LEFT

LEFT ---> D5 //RIGHT


- Key Code

void setup() {

  Serial.begin(9600);

  pinMode(2, INPUT_PULLUP); // UP

  pinMode(3, INPUT_PULLUP); // DOWN

  pinMode(4, INPUT_PULLUP); // LEFT

  pinMode(5, INPUT_PULLUP); // RIGHT 

 }

 

void loop() {


  int up = digitalRead(2);

  int down = digitalRead(3);

  int left = digitalRead(4);

  int right = digitalRead(5);

 

  Serial.print("up(D2)="+(String)up);

  Serial.print(" down(D3)="+(String)down);

  Serial.print(" left(D4)="+(String)left);

  Serial.println(" right(D5)="+(String)right);

  Serial.println();

 

  if(up == LOW && left == LOW) 

  {    

    Serial.println("Location ==========> UP + LEFT     ");

  }

  else if(up == LOW && right == LOW)

  {

      Serial.println("Location ==========> UP + RIGHT    ");

  }

  else if(down == LOW && left == LOW)

  {

      Serial.println("Location ==========> DOWN + LEFT    ");

  }

  else if(down == LOW && right == LOW)

  {

      Serial.println("Location ==========> DOWN + RIGHT     ");

  }

  else if(up == LOW)

  {

      Serial.println("Location ==========> UP             ");

  }

  else if(down == LOW)

  {

      Serial.println("Location ==========> DOWN             ");

  }

  else if(left == LOW)

  {

      Serial.println("Location ==========> LEFT             ");

  }

  else if(right == LOW)

  {

      Serial.println("Location ==========> RIGHT            ");

  }

  delay(200); 

 

}



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

XY-axis Joystick Module (KY-023) [S056]  (0) 2016.09.12
Posted by RDIoT
|

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
|