stoppuhr

Dependencies:   C12832 mbed

Revision:
0:1237acf021fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 18 12:07:25 2015 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+#include "C12832.h"
+
+Ticker Tick;
+InterruptIn button1(p15);
+InterruptIn button2(p12);
+InterruptIn button3(p14);
+
+Serial pc(USBTX, USBRX);
+
+C12832 lcd(p5, p7, p6, p8, p11);
+
+float a;
+int msek;
+int sek;
+int min;
+int stund;
+bool mode;
+
+
+void zaehl()
+{
+    if(mode==true) {
+        msek++;
+        if(msek==100) {
+            sek++;
+            msek=0;
+            
+            pc.printf("Stu:%d  Min:%d  Sek:%d \n",stund, min, sek);
+        }
+
+        if(sek==60) {
+            min++;
+            sek=0;
+
+        }
+
+        if(min==60) {
+            stund++;
+            min=0;
+        }
+        if(stund==24) {
+            msek=0;
+            sek=0;
+            min=0;
+            stund=0;
+        }
+
+    }
+     
+}
+
+void on()
+{
+    mode=true;
+}
+
+void off()
+{
+    mode=false;
+}
+
+void reset()
+{
+    msek=0;
+    sek=0;
+    min=0;
+    stund=0;
+}
+
+int main()
+{
+    Tick.attach(&zaehl, 0.01);
+    button1.rise(&on);
+    button2.rise(&off);
+    button3.rise(&reset);
+
+    mode=false;
+    
+    lcd.cls();
+    lcd.locate(0,3);
+    
+    while(1) {
+            lcd.printf("Stu:%d  Min:%d  Sek:%d ",stund, min, sek);
+            lcd.locate(0,3);
+
+    }
+}
\ No newline at end of file