small medium large xlarge

Back to: All Forums  Arduino
Dennis_3_small_pragsmall
15 Feb 2011, 03:49
Dennis Martinez (2 posts)

Hi,

First off, let me thank you for writing this wonderful book. I studied electronics in high school (more than 12 years ago) but I never really followed up on it after my courses, so I really forgot a lot of what I learned. The Arduino - and this book - is reminding me why I studied electronics in the first place. I love it!

Anyway, I have a slight confusion regarding pushbuttons on the Arduino. I’m currently reading Chapter 3: Building Binary Dice. In the book, it specifies that when the button is unpressed, the default value is LOW. However, in my case, it’s the inverse - When the button is unpressed (connected exactly as specified in the book), I get a HIGH read, and when I press the button I get a LOW read. This is what Arduino’s Pushbutton tutorial (http://www.arduino.cc/en/Tutorial/Pushbutton) says as well. When writing the code, if I change HIGH to LOW and vice versa, the sketch works properly when uploaded to the Arduino.

Am I connecting something incorrectly? Are there differences between pushbuttons? I’m just a little confused on this. Thanks!

Maik_schmidt_avatar2_pragsmall
15 Feb 2011, 16:18
Maik Schmidt (122 posts)

Hi Dennis!

First off, let me thank you for writing this wonderful book. I studied electronics in high school (more than 12 years ago) but I never really followed up on it after my courses, so I really forgot a lot of what I learned. The Arduino – and this book – is reminding me why I studied electronics in the first place. I love it!

Thank you very much! I am always glad to hear that! Oh, and I don’t mind if you share your opinion on Amazon :-)

Anyway, I have a slight confusion regarding pushbuttons on the Arduino. I’m currently reading Chapter 3: Building Binary Dice. In the book, it specifies that when the button is unpressed, the default value is LOW. However, in my case, it’s the inverse – When the button is unpressed (connected exactly as specified in the book), I get a HIGH read, and when I press the button I get a LOW read. This is what Arduino’s Pushbutton tutorial (http://www.arduino.cc/en/Tutorial/Pushbutton) says as well. When writing the code, if I change HIGH to LOW and vice versa, the sketch works properly when uploaded to the Arduino.

Am I connecting something incorrectly? Are there differences between pushbuttons? I’m just a little confused on this. Thanks!

There are no major differences between pushbuttons but there are different ways of wiring them. Another tutorial on the Arduino web site (http://arduino.cc/it/Tutorial/Button) explains this behavior nicely:

bq. You can also wire this circuit the opposite way, with a pullup resistor keeping the input HIGH, and going LOW when the button is pressed. If so, the behavior of the sketch will be reversed, with the LED normally on and turning off when you press the button.

Still it might well be that I have mixed up LOW and HIGH in the code. What example are you referring to?

Best Maik

Oppa2_pragsmall
15 Feb 2011, 18:20
Stephan Goldenberg (14 posts)

Down to figure 3.8, page 75 methinks. Code is correct, HIGH active. button pressed = HIGH = LED on.

Did you confuse polarity ? Assuming current flows from plus to ground it has to be:

plus —- button —- resistor —- ground arduino input is floating when not pressed, if you push the button the input pin gets connected to plus = HIGH.

I guess you have: plus —- resistor —- button —- ground

Well, works for me at least. :) This floating input pin is still confusing me…

Dennis_3_small_pragsmall
16 Feb 2011, 04:25
Dennis Martinez (2 posts)

I just rewired everything on my breadboard and it’s working correctly now! I think my mistake was that I had the resistor incorrectly placed on the breadboard, although I’m not sure if that was the issue. Oh well, at least I learned something new about pushbuttons. Thanks for the help!

You must be logged in to comment