Description
Joystick XY duo axis with button module KY-023. Add this to your robot, smart car or game project for control. Easy to connect to an Arduino with 2 analog pins for XY control. The button can be connected to a digital pin.
€1,95
Joystick XY duo axis module KY-023
5 in stock
Joystick XY duo axis with button module KY-023. Add this to your robot, smart car or game project for control. Easy to connect to an Arduino with 2 analog pins for XY control. The button can be connected to a digital pin.
int sensorPin = 5;
int value = 0;
void setup() {
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void loop() {
value = analogRead(0);
Serial.print("X:");
Serial.print(value, DEC);
value = analogRead(1);
Serial.print(" | Y:");
Serial.print(value, DEC);
value = digitalRead(7);
Serial.print(" | Z: ");
Serial.println(value, DEC);
delay(100);
} Only logged in customers who have purchased this product may leave a review.
Nathan -
The pin you connect your SW to must use an internal pullup resistor.
Below is the modified code:
int sensorPin = 7;
int value = 0;
void setup () {
pinMode(sensorPin, INPUT_PULLUP);
Serial.begin (9600);
}
void loop () {
value = analogRead(A0);
Serial.print(“X:”);
Serial.print(value, DEC);
value = analogRead(A1);
Serial.print(” | Y:”);
Serial.print(value, DEC);
value = digitalRead(sensorPin);
Serial.print(” | Z: “);
Serial.println(value, DEC);
delay (100);
}