Pages: [1]   Go Down
Author Topic: Rising and falling edge  (Read 2652 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
i tough i read somewhere on the internet that a digitalRead instruction could detect a rising and falling edge. For some reason I can’t find it anymore. Maybe it was another instruction…
Anyway I need to detect the rising and falling edge of a pushbutton on a digital input, any help would be appreciated.

Thanks,
Chris
Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50157
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The digitalRead() function determines whether the current state of the pin is HIGH or LOW. An interrupt can be captured, using an external interrupt, on the change from LOW to HIGH, from LOW to HIGH, or either change.

The pulseIn() function can tell you how long a pin is HIGH or LOW, when the change is caused by something other than a push-button switch.
Logged

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/DigitalRead digitalRead
http://arduino.cc/en/Reference/AttachInterrupt external interrupts
http://arduino.cc/en/Reference/PulseIn pulseIn

http://arduino.cc/en/Tutorial/Button Using digitalRead
http://arduino.cc/en/Tutorial/ButtonStateChange edge detection

They should explain interrupts, digitalRead, pulseIn, and reading pins with digitalRead. After you've mastered that, you can try learning port manipulation for faster digitalReads.

Onions.
Logged

My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) smiley-grin

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for pointing me in the right direction guys . I can probably work something out with the ButtonStateChange code.

Cheers,
Chris
Logged


Pages: [1]   Go Up
Jump to: