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.
main.cpp@0:780c50a3df4e, 2021-09-21 (annotated)
- Committer:
- cspista
- Date:
- Tue Sep 21 14:22:14 2021 +0000
- Revision:
- 0:780c50a3df4e
- Child:
- 1:fdf1b69c81b6
MBED2 project
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cspista | 0:780c50a3df4e | 1 | include "mbed.h" |
| cspista | 0:780c50a3df4e | 2 | |
| cspista | 0:780c50a3df4e | 3 | DigitalOut myled(LED1); // PA_5 alias LED1 |
| cspista | 0:780c50a3df4e | 4 | DigitalIn mybutton(BUTTON1,PullUp); // PC13 alias BUTTON1 |
| cspista | 0:780c50a3df4e | 5 | int bState, waitforpress=1, led_state=0; |
| cspista | 0:780c50a3df4e | 6 | int main() |
| cspista | 0:780c50a3df4e | 7 | { |
| cspista | 0:780c50a3df4e | 8 | while(1) { |
| cspista | 0:780c50a3df4e | 9 | bState = mybutton; |
| cspista | 0:780c50a3df4e | 10 | if(waitforpress) { //Ha lenyomásra várunk és |
| cspista | 0:780c50a3df4e | 11 | if(!bState) { //Ha lenyomás történt... |
| cspista | 0:780c50a3df4e | 12 | led_state = !led_state; //LED állapotának átbillentése |
| cspista | 0:780c50a3df4e | 13 | myled = led_state; |
| cspista | 0:780c50a3df4e | 14 | waitforpress = false; //Következő stáció: felengedésre várunk |
| cspista | 0:780c50a3df4e | 15 | } |
| cspista | 0:780c50a3df4e | 16 | } else { //Ha felengedésre vártunk és |
| cspista | 0:780c50a3df4e | 17 | if(bState) { //Ha felengedést észlelünk... |
| cspista | 0:780c50a3df4e | 18 | waitforpress = true; //Következő stáció: lenyomásra várunk |
| cspista | 0:780c50a3df4e | 19 | } |
| cspista | 0:780c50a3df4e | 20 | } |
| cspista | 0:780c50a3df4e | 21 | wait(0.02); // 20 ms pergésmentesítő késleltetés |
| cspista | 0:780c50a3df4e | 22 | } |
| cspista | 0:780c50a3df4e | 23 | } |