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.
SwitchONledBlinkss5secs.cpp@2:48d0e4493777, 2021-06-01 (annotated)
- Committer:
- goddyy
- Date:
- Tue Jun 01 13:44:16 2021 +0000
- Revision:
- 2:48d0e4493777
Yellow LED will Blink for 5secs when switch is ON
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| goddyy | 2:48d0e4493777 | 1 | #include "mbed.h" |
| goddyy | 2:48d0e4493777 | 2 | |
| goddyy | 2:48d0e4493777 | 3 | DigitalOut yellowled(p5); |
| goddyy | 2:48d0e4493777 | 4 | DigitalIn switchbutton(p10); |
| goddyy | 2:48d0e4493777 | 5 | |
| goddyy | 2:48d0e4493777 | 6 | int i=0; |
| goddyy | 2:48d0e4493777 | 7 | void Blink(){ |
| goddyy | 2:48d0e4493777 | 8 | while(i<5){ |
| goddyy | 2:48d0e4493777 | 9 | yellowled=0; |
| goddyy | 2:48d0e4493777 | 10 | wait(0.5); |
| goddyy | 2:48d0e4493777 | 11 | yellowled=1; |
| goddyy | 2:48d0e4493777 | 12 | wait(0.5); |
| goddyy | 2:48d0e4493777 | 13 | i++; |
| goddyy | 2:48d0e4493777 | 14 | } |
| goddyy | 2:48d0e4493777 | 15 | yellowled=0; |
| goddyy | 2:48d0e4493777 | 16 | } |
| goddyy | 2:48d0e4493777 | 17 | int main(){ |
| goddyy | 2:48d0e4493777 | 18 | while (1){ |
| goddyy | 2:48d0e4493777 | 19 | if(switchbutton==1) |
| goddyy | 2:48d0e4493777 | 20 | { |
| goddyy | 2:48d0e4493777 | 21 | Blink(); |
| goddyy | 2:48d0e4493777 | 22 | } |
| goddyy | 2:48d0e4493777 | 23 | i=0; |
| goddyy | 2:48d0e4493777 | 24 | wait(0.5); |
| goddyy | 2:48d0e4493777 | 25 | } |
| goddyy | 2:48d0e4493777 | 26 | } |