Arduino
/*******************************************************
* name:Joystick PS2
* function:push the joystick and the coordinates of X and Y axes displayed on Serial Monitor will change accordingly;
* press down the joystick, and the coordingly of Z=0 will also be displayed.
* connection:
* Joystick PS2 Arduino Uno R3
* GND GND
* VCC 5V
* SW 7
* x A0
* Y A1
* ******************************************************/
const int xPin = A0; //X attach to A0
const int yPin = A1; //Y attach to A1
const int btPin = 7; //Bt attach to digital 7
void setup()
{
pinMode(btPin, INPUT);
digitalWrite(btPin, HIGH);
Serial.begin(9600);
}
void loop()
{
Serial.print("X: "