Pages: [1]   Go Down
Author Topic: Silly question about Examples in Arduino Enivronment  (Read 426 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear All,

A real numpty question,

The examples in the Arduino environment, Button and Debounce,

I have connected a push to make switch to the board as described and checked with the DigitalReadSerial example. So i am getting logic level 1 and 0.

Am i right in saying, that when the button is pushed the LED should remain on all the time the button is pushed? and then as soon as you release the button, it should turn the LED off.

OR

Do you push the button once for ON and once for OFF

Please can someone confirm
Thanks
Martyn

Please can someone confirm as i am concerned I've done something wrong.


Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23835
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the code can be written for either.
Press & hold for one level, or press & release for a state change (1-0, 0-1) with every button press.
I've not used either example personally, but written similar functionality into my code,
usually performing some action when I detect a low (button pressed to ground a pin that has internal pullup enabled) and if the ensuing code is too quick, adding a slight delay for debug.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please can someone confirm as i am concerned I've done something wrong.

Test it and see? If it doesn't do what you expect:

  • Tell us what you expect
  • Tell us what actually happens
  • Post your code
  • Show your wiring
Logged

Salem, Oregon
Offline Offline
Sr. Member
****
Karma: 2
Posts: 275
Friends don't let friends use Strings
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Am i right in saying, that when the button is pushed the LED should remain on all the time the button is pushed? and then as soon as you release the button, it should turn the LED off.

Sounds exactly right to me.  The Button example clearly only will illuminate the LED when the button reads HIGH.

The Debounce example has misleading comments - the comments imply the LED only changes when the state goes LOW to HIGH when in reality any time the state changes from the previous (after 10 millis anyways) the LED will change state as well.

So in effect the Debounce example is just a different way of doing the same thing. 

I hope this helps,

Brad (KF7FER)
Logged

Pages: [1]   Go Up
Jump to: