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.
Diff: main.cpp
- Revision:
- 0:780c50a3df4e
- Child:
- 1:fdf1b69c81b6
diff -r 000000000000 -r 780c50a3df4e main.cpp
--- /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