I am using a thumb joystick for Arduino UNO, trying to work with it.
There are x
and y
values that I get with analog input A0
and A1
, and one z
value for the click that I should have gotten from the digital input D7
, but unfortunately I wired it to another anolog input (A3
).
This is the wiring from the specification
So, now that I fixed my mistake, I get the x
from A1
and y
from A2
, but z
is always zero. Is there a chance that the joystick part is physically damaged? Or worse, my Arduino UNO? How can I check?
int sensorPin = 5;
int value = 0;
void setup() {
pinMode(7, 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);
}
Chinese specific specification is here. I wish it was also available in English! :-/
digitalRead(7)
. Isn't it the case? Btw, Google translate did a good job in translating from Chinese to English for me; Unfortunately after the fact. :-/ \$\endgroup\$