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

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);
void loop() {
  value = analogRead(0);
  Serial.print(value, DEC);
  value = analogRead(1);
  Serial.print(" | Y:");
  Serial.print(value, DEC);
  value = digitalRead(7);
  Serial.print(" | Z: ");
  Serial.println(value, DEC);

Chinese specific specification is here. I wish it was also available in English! :-/

  • 2
    \$\begingroup\$ I doubt you damaged anything. And I do not speak Chinese. But it looks to me that the wiring instructions for the z axis are missing, so... How did you wire it? \$\endgroup\$ Commented Nov 24, 2016 at 21:52
  • \$\begingroup\$ @VladimirCravero By looking at the code. It's reading from the digital pin 7 in 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\$
    – Ho1
    Commented Nov 24, 2016 at 21:53
  • 2
    \$\begingroup\$ try pinMode(7, INPUT) instead of OUTPUT \$\endgroup\$
    – Wesley Lee
    Commented Nov 24, 2016 at 21:54
  • 1
    \$\begingroup\$ What Weslesy said, definitely. And I asked how you wired, i.e. connected, it, not how you're attempting to read it. \$\endgroup\$ Commented Nov 24, 2016 at 21:55
  • \$\begingroup\$ @VladimirCravero I tried to find out about wiring from the code, because I coudln't find anything useful in the specification itself. I found that it is reading from the digital input 7, so I changed my wiring and connected it to digital section, number 7. \$\endgroup\$
    – Ho1
    Commented Nov 24, 2016 at 22:08

1 Answer 1


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.

  • \$\begingroup\$ The code is actually from the specification, and I think it reads from digital pin by setting pinMode(7, OUTPUT) and then digitalRead(7). Isn't it the case? \$\endgroup\$
    – Ho1
    Commented Nov 24, 2016 at 21:56
  • \$\begingroup\$ Please do not be offended, but your "Question" is not about that. It is about whether or not you have damaged your device. :) It is not meaningful to read values from an output pin, since your own code sets the output value itself. \$\endgroup\$
    – user98663
    Commented Nov 24, 2016 at 21:59
  • \$\begingroup\$ @Ho1 -- If you need a source to feel better, read a button state by using pinMode(X, INPUT): arduino.cc/en/Tutorial/Button \$\endgroup\$
    – Wesley Lee
    Commented Nov 24, 2016 at 22:01
  • \$\begingroup\$ @Ho1 -- Actually it can be more harmful to set a pin as Output and then short it to 5V or GND with a button than switching analogRead for digitalRead. \$\endgroup\$
    – Wesley Lee
    Commented Nov 24, 2016 at 22:03
  • 1
    \$\begingroup\$ I suspect that your changing "OUTPUT" to "INPUT" on pin 7 solved it for you but for future reference, you can either just upload a screenshot of your diagram or use the stack exchange circuit diagram editor, which you can activate by clicking the icon in the "question editor" toolbar. Personally I just upload a picture most of the time. \$\endgroup\$
    – user98663
    Commented Nov 24, 2016 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.