Go Down

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

ElectricalStorm

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
U2 Rules

http://www.r2belgium.tk

PaulS

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.

Onions

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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

ElectricalStorm

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

Cheers,
Chris
U2 Rules

http://www.r2belgium.tk

Go Up