blink

Dependencies:   mbed C12832

Revision:
0:cd13fa587caf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jul 07 20:06:50 2019 +0000
@@ -0,0 +1,113 @@
+
+
+
+
+
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#include "mbed.h"
+#include "C12832.h"
+Timer debounce;
+InterruptIn prekid(p14);
+PwmOut speaker(p26);
+C12832 lcd(p5, p7, p6, p8, p11);
+
+int count;
+
+void broj()
+{
+    if (debounce.read_ms() > 20)
+        {
+            ::count++;
+            debounce.reset();
+        }
+
+}
+
+int main()
+{
+    debounce.start();
+    prekid.rise(&broj);
+
+    while(1)
+        {
+            switch(::count)
+                {
+                    case 1:
+                    speaker.period(1.0/1000);
+                    speaker = 0.5;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm %d\ Volume = %f", ::count, speaker);
+                    break;
+
+                    case 2:
+                    speaker.period(1.0/2000);
+                    speaker = 0.5;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm %d\ Volume = %f", ::count, speaker);
+                    break;
+
+                    case 3:
+                    speaker.period(1.0/4000);
+                    speaker = 0.5;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm %d\ Volume = %f", ::count, speaker);
+                    break;
+
+                    case 4:
+                    speaker.period(1.0/8000);
+                    speaker = 0.5;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm %d\ Volume = %f", ::count, speaker);
+                    break;
+
+                    case 5:
+                    speaker.period(1.0/13000);
+                    speaker = 0.5;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm %d\ Volume = %f", ::count, speaker);
+                    break;
+
+                    default:
+                    speaker = 0.0;
+                    lcd.locate(0,3);
+                    lcd.printf("Alarm off");
+                    break;
+
+
+                }
+
+            if(::count>5)
+                {::count=0;}
+        }
+
+}