Hey all!
So I'm a longtime lurker, first time poster, and I'm having a really odd problem with my Leonardo.
I had hooked up some momentary push buttons (open when unpressed) into digital pins 2,3,4 and 5 with the goal of making a really simple binary calculator (each button represents a bit). I hooked up 4 LED's to pins 6,7,8 and 9 and set up a really quick test to make sure everything was wired correctly. All the buttons were wired up to 3.3 volts and all the LED's to the common ground.
I initialized all the pins and wrote the following lines into loop().
void loop()
{
digitalWrite(pin6,digitalRead(pin2));
digitalWrite(pin7,digitalRead(pin3));
//etc...
}
The button on pin 2 worked fine; when I pushed the button, the light on pin 6 turned on pretty much instantly, and went off again once I released the button. The button on pin 3 also worked fine (although I noticed a very small, but noticeable, lag).
Things got weird though with the button on pin 4. Somehow the lights on both pin 6 and pin 7 turned on, although the one on pin 7 was much brighter than the one on pin 6. I measured the voltage, and pin 7 had approximately double the voltage of pin 6. The button on pin 5 doesn't seem to do anything at all, but the light flashes erratically.
Do I need to use IORef to power my buttons? I read somewhere that IORef just outputs the voltage that the board is running at for shields and stuff (which would translate to 5 volts in the case of the Leonardo) I tried putting 5 volts instead of 3.3 into the buttons, but that didn't change anything. I also confirmed that it wasn't the buttons, I switched them around in every combination I could think of, and that didn't affect anything. So, I'm assuming it's probably bad pins.
Is there anything I can do to diagnose what's going on and potentially fix it?