ok - fix input pin

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
avnisha
Date:
Wed Aug 07 19:44:57 2013 +0000
Commit message:
ok

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 801eef032b63 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 07 19:44:57 2013 +0000
@@ -0,0 +1,30 @@
+
+#include "mbed.h"
+ 
+class Counter {
+public:
+    Counter(PinName pin) : _interrupt(pin) {        // create the InterruptIn on the pin specified to Counter
+        _interrupt.rise(this, &Counter::increment); // attach increment function of this counter instance
+    }
+ 
+    void increment() {
+        _count++;
+    }
+ 
+    int read() {
+        return _count;
+    }
+ 
+private:
+    InterruptIn _interrupt;
+    volatile int _count;
+};
+ 
+Counter counter(p5);
+ 
+int main() {
+    while(1) {
+        printf("Count so far: %d\n", counter.read());
+        wait(2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 801eef032b63 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Aug 07 19:44:57 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e3affc9e7238
\ No newline at end of file