Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:a082d4766316, committed 2018-11-15
- Comitter:
- martwerl
- Date:
- Thu Nov 15 17:57:17 2018 +0000
- Commit message:
- Btn_Runlight_Polling
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:57:17 2018 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+
+//Lauflicht, das sich bei jedem Button-Click um 1 weiterbewegt
+//Das ist die Polling Lösung
+
+// 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
+//BusIn btn(P0_10,P0_15,P0_23,P1_16); //Ausgabe für eine Bitgruppe
+
+DigitalIn sw4(P1_16); //Taster
+int PrevSW4 = 0;//Schalterzustand, wie er bei der letzten Abfrage war
+
+void OneRunLightStep(); //einen Schritt eines Lauflichts ausführen
+int CheckButton();
+
+
+int main()
+{
+ lb = 1;
+ while(1) {
+ if(CheckButton() )
+ OneRunLightStep();
+ }
+}
+
+int CheckButton()
+{
+ int ret = 0;
+ if(sw4 == 1 && PrevSW4 == 0)//Taster gedrückt und alter Schalterzustand 0
+ ret = 1;
+ else
+ ret = 0;
+ PrevSW4 = sw4; //alten Schalterzustand merken
+ return ret;//wenn 1 retouniert wird, wird Funktion OneRunLightStep() aufgerufen
+}
+
+
+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:57:17 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file