Code-Basis für Programm zum Taster-Entprellen

Dependencies:   SB1602E mbed

Fork of Laser-Distance by Stefan Kummer

Revision:
11:b68be9bd5754
Parent:
10:f727c310c86f
Child:
12:b436e51e86a8
--- a/main.cpp	Sun Sep 30 21:33:03 2018 +0000
+++ b/main.cpp	Mon Oct 01 09:17:01 2018 +0000
@@ -3,23 +3,44 @@
 #define USE_I2C_2V8
 
 DigitalOut myled(P0_8); // 7=rot, 8=grün, 9=blau
-DigitalIn sw_o(P0_12);
-DigitalIn sw_b(P0_13);
-DigitalIn sw_g(P0_14);
+InterruptIn sw_o(P0_12);
+InterruptIn sw_b(P0_13);
+InterruptIn sw_g(P0_14);
 
 I2C i2c_disp(P0_5, P0_4); //  SDA, SCL auf LPC11U24
 SB1602E lcd(i2c_disp);
 
 int count_o, count_b, count_g = 0;
 
+void orange();
+
+void blue(){
+    count_b++;
+    }
+void green() {
+    count_g++;
+    }
+
 int main()
 {
+    sw_o.mode(PullUp);
+    sw_b.mode(PullUp);
+    sw_g.mode(PullUp);
+    sw_o.fall(&orange);
+    sw_b.fall(&blue);
+    sw_g.fall(&green);
+    
+    
     lcd.printf(0, "Red Blue Green\r");    //  Parameter von printf auf LCD: Zeilennummer (0 or 1), string
     while(1) {
 
-        lcd.printf( 1, "%d   %d   %d", count_o, count_b, count_g);
+        lcd.printf(1, "%d   %d   %d", count_o, count_b, count_g);
 
         myled = !myled;
 
     }
+}
+
+void orange() {
+    count_o++;
 }
\ No newline at end of file