Go Down

Topic: Rising and falling edge (Read 4437 times) previous topic - next topic

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.

U2 Rules



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.


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.

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

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

U2 Rules


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131