This is a very simple way to count DigitalIn rising by using Ticker Interrupts.

Dependencies:   mbed

Committer:
MBE13170
Date:
Thu Dec 23 07:48:27 2010 +0000
Revision:
0:d8173cfb7a78

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MBE13170 0:d8173cfb7a78 1 #include "mbed.h"
MBE13170 0:d8173cfb7a78 2 #include "Pswitch.h"
MBE13170 0:d8173cfb7a78 3
MBE13170 0:d8173cfb7a78 4 DigitalOut led(LED1);
MBE13170 0:d8173cfb7a78 5 Pswitch button(p21);
MBE13170 0:d8173cfb7a78 6
MBE13170 0:d8173cfb7a78 7 int main() {
MBE13170 0:d8173cfb7a78 8
MBE13170 0:d8173cfb7a78 9 while(1) {
MBE13170 0:d8173cfb7a78 10 if (button.count() > 0){
MBE13170 0:d8173cfb7a78 11 led = !led;
MBE13170 0:d8173cfb7a78 12 }
MBE13170 0:d8173cfb7a78 13 }
MBE13170 0:d8173cfb7a78 14
MBE13170 0:d8173cfb7a78 15 }