Rising and falling edge

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

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.

Onions.

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

Cheers,
Chris

Onions:
http://arduino.cc/en/Reference/DigitalRead digitalRead
attachInterrupt() - Arduino Reference 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.

The page "Reference/DigitalReadDigitalRead" doesn't exist.
The page "Reference/AttachInterruptExternalInterrupts" doesn't exist.

Reference Home

anton1o:
The page "Reference/DigitalReadDigitalRead" doesn't exist.
The page "Reference/AttachInterruptExternalInterrupts" doesn't exist.

But the given links do.

http://arduino.cc/en/Reference/DigitalRead digitalRead
attachInterrupt() - Arduino Reference external interrupts

Did you really have to kick a nearly 6 year old thread?

jurs:
Have you worked through the most basic programming examples, included in the Arduino IDE?

The flank detection example is the "StateChangeDetection" example. Simply open it under menu option "File-Examples"

Did you read reply #4 and reply #6? :smiley:

Whandall:
But the given links do.

I just make message to fix the link on that post #2

Don't fix something that is not broken.
After six years it would be rather pointless, even it it were broken.

BTW nobody can fix the way you copy links.

rising and falling edge of a push button

  1. A push button has no edge; it has pins.

  2. An electrical full pulse (|----| ; AL, RE, AH, FE) signal has edges in addition to active levels.

  3. What do you want now?
    (a) Sensing the RE (Rising Edge = Leading Edge) of an incoming pulse and then trigger an event.
    (b) Sensing the FE (Falling Edge = Training Edge) of an incoming pulse and then trigger an event.

  4. Is it possible to create a full electrical pulse using a push button?
    yes.
    Let us trigger a 74LS123 type one-shot by a push button.

  5. The RE of the resultant pulse can be detected by the MCU being interrpted over INT0-pin.

  6. The RE of the resultant pulse can also be detected by counting the RE of the incoming pulse
    using T0-pin.