Buttontest

Dependencies:   mbed

Revision:
0:c77311b3735e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 24 16:00:53 2016 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+//        LSB...                                                   ...MSB
+//        2^0   2^1 ...........
+BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
+//          D20   D19  D18.....
+
+BusIn btn(P0_10, P0_15, P0_23, P1_16);
+int main() {
+ lb = 0;//alle Leds aus
+
+ while(1)
+ {
+        if (btn & 1)//wenn sw1 gedrückt
+            lb = lb | 4;
+        
+        if (btn & 2)//wenn sw2 gedrückt
+            lb = lb | 8;
+            
+        if (btn & 4)//wenn sw2 gedrückt
+            lb = lb | 16;
+        
+        if (btn & 8)//wenn sw2 gedrückt
+            lb = lb | 32;
+            
+            wait_ms(100);
+            lb = 0;
+            wait_ms(100);
+ 
+ }
+}