István Cserny / Mbed 2 deprecated Lab01_button_ledswitch

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
cspista
Date:
Tue Sep 21 14:22:14 2021 +0000
Child:
1:fdf1b69c81b6
Commit message:
MBED2 project

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	Tue Sep 21 14:22:14 2021 +0000
@@ -0,0 +1,23 @@
+include "mbed.h"
+
+DigitalOut myled(LED1);                 // PA_5 alias LED1
+DigitalIn mybutton(BUTTON1,PullUp);     // PC13 alias BUTTON1
+int bState, waitforpress=1, led_state=0;
+int main()
+{
+    while(1) {
+        bState = mybutton;
+        if(waitforpress) {              //Ha lenyomásra várunk és
+            if(!bState) {               //Ha lenyomás történt...
+                led_state = !led_state; //LED állapotának átbillentése
+                myled = led_state;
+                waitforpress = false;   //Következő stáció: felengedésre várunk
+            }
+        } else {                        //Ha felengedésre vártunk és
+            if(bState) {                //Ha felengedést észlelünk...
+                waitforpress = true;    //Következő stáció: lenyomásra várunk
+            }
+        }
+        wait(0.02);                     // 20 ms pergésmentesítő késleltetés
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 21 14:22:14 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file