I'm making my way through the introductory tutorials, and I have run across a situation I don't understand. In the Button tutorial, HIGH and LOW seem to be reversed. I tried this using both the switch and LED on my protoboard, and also straight breadboard wiring as described in "Getting Started with Arduino" from Make. I tried changing from pin 13 to pin 12. The behavior of the illustration is always in reverse (light is on by default and pressing the button turns it off). I was able to get it to work as expected by changing this:
if (buttonState == HIGH)
to this:
if (buttonState == LOW)
I am an experienced C# programmer, and somewhat experienced with electronics. Can someone please help me to understand what's going on here?
Okay, I didn't read the instructions for my prototype shield closely enough:
The button on the ProtoShield is 'pulled high', meaning one side of the button is connected, through a resistor, to +5V and also to 'JC1' (which should then be connected to an Arduino pin of your choice). The other end of the button is simply connected to ground. This means that when the button is pressed it will read as LOW, otherwise it will be HIGH. In the example above, the LED will be on unless the button is being pressed.
Apologies. Hopefully my next question will be more interesting. Thanks for your patience!