Electronic – Arduino: Did I damage analog joystick clicker by using analog instead of digital input

analogarduinodamagedigital-logic

I am using a thumb joystick for Arduino UNO, trying to work with it.

joystick

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

wiring details

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! :-/

Best Answer

Did I damage analog joystick clicker by using analog instead of digital input?

No. Neither mode will draw damaging amounts of current through the device.

But it does look like you've set pin 7 to be an output, and are trying to read digital values from that pin. Is that what you intended? :)

Make it an input instead and generally give your code a close examination line by line.

Further info: Setting a pin to be an input will configure your microcontroller to use "High-Z" mode on that particular pin. This means that the pin becomes a high impedance input ("Z" is the standard letter for impedance). This means that almost no current is able to be either drawn from, or sunk into, that pin.

While in High-Z state (also known as "tri-stated", or simply as "input") this pin is able to do either digital input readings (logic levels... 0's and 1's) or analog readings (an 8-bit analog input is able to give you a value between 0x00 and 0xff), which you can scale mathematically to a voltage between 0V and VCC.