Btn_Runlight2Interrupt

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
martwerl
Date:
Thu Nov 15 17:56:48 2018 +0000
Commit message:
Btn_Runlight2Interrupt

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	Thu Nov 15 17:56:48 2018 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+
+//Lauflicht, das sich bei jedem Button-Click um 1 weiterbewegt
+//Lösung Interrupt!!!!!!!!!!!!!!!!!!!!
+
+// LSB MSB
+// 2^0 2^1 2^2 2^11
+BusOut lb(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); // Ausgabe für eine Bit Gruppe
+// D20 D19 D18 D17 D16 D15 D14 D13 D4 D3 D2 D1
+// SW1 SW2 SW3 SW4
+// Bit0 Bit1 Bit2 Bit3
+
+
+//SW4 als Interrupt konfigurieren
+InterruptIn sw4(P1_16);//Taster
+
+//void SW4ISR();
+void OneRunLightStep(); //einen Schritt eines Lauflichts ausführen
+//diese Funktion wird aufgerufen, wenn die MC-Hardware eine steigende Flanke an SW4 erkannt hat
+
+void SW4ISR()
+{
+    if(sw4.read() )//nochmal fragen, ob Taster sw4 noch 1 ist
+        OneRunLightStep();
+}
+
+int main()
+{
+    lb = 0;
+    sw4.rise(SW4ISR);//der MC-Hardware sagen, dass sie SW4ISR()aufrufen soll, wenn die steigende Flank erkannt wurde
+    
+    while(1)//das Hauptporogramm hat in diesem Fall nichts sinnvolles zu tun
+    {
+        
+    }
+    
+}
+
+void OneRunLightStep()
+{
+    if(lb == 0)//wenns finster ist...
+        lb = 1;//einschalten
+    else
+        lb = lb << 1;//...um 1 nach links schieben
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 17:56:48 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file