mbed_binary_counter

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
foivosHrist
Date:
Tue Oct 07 23:55:54 2014 +0000
Child:
1:4e311ab3af04
Commit message:
for LPC1768 platform

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 07 23:55:54 2014 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#define PRESSED 0
+#define UNPRESSED 1
+
+int getNext();
+
+DigitalIn pin8(p8); //button on pin8
+BusOut counter(LED4, LED3, LED2, LED1);
+ 
+//----------------------------------------------- 
+int main() {
+    
+    pin8.mode(PullUp); //set internal pullup
+    
+    bool previousState=pin8;
+    bool currentState;
+   
+    while(1) {
+        
+        currentState=pin8;
+        if(currentState==PRESSED && previousState==UNPRESSED){
+              counter=getNext();  
+            
+        }
+        previousState=currentState;
+        wait(0.1);
+        
+        
+        
+    }
+}
+
+
+//-----------------------------------------------
+int getNext(){
+    static int i=0;
+    if(i==15)i=0;
+    else i++;
+    
+    return i;
+    
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 07 23:55:54 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file