Go Down

Topic: Leonardo analog pins not acting as digital pins? [Solved] (Read 796 times) previous topic - next topic


Jan 02, 2013, 08:22 am Last Edit: Jan 02, 2013, 11:58 pm by davenunez Reason: 1
I got a new Leonardo, and have set up a simple button test (button with a 10k ohm resistor, as described in the Button tutorial). Works great on Pin 0, but when I move it to Pin 14 (A0 on the board), it does not work - pushing the button does nothing, and the data coming back from the pin seems either all 0 or random (if you move it to another digital pin such as 2, it works great). Here is the code I used. Am I missing something?
Code: [Select]

//change buttonPin to 14 and move the input to pin A0, and the code stops working as expected.
int buttonPin = 0;

void setup()
 pinMode(buttonPin, INPUT);

void loop()
 int s = digitalRead(buttonPin);


On the Leonardo, A0 is pin 18, not 14.  Use the name A0 if you want your code to work on multiple platforms.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131