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
|