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:f9a53979b663, 2014-10-18 (annotated)
- Committer:
- chenlaoshi
- Date:
- Sat Oct 18 03:02:41 2014 +0000
- Revision:
- 0:f9a53979b663
???
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| chenlaoshi | 0:f9a53979b663 | 1 | #include "mbed.h" |
| chenlaoshi | 0:f9a53979b663 | 2 | |
| chenlaoshi | 0:f9a53979b663 | 3 | DigitalOut myled(PA_5); |
| chenlaoshi | 0:f9a53979b663 | 4 | void delay(long int i); |
| chenlaoshi | 0:f9a53979b663 | 5 | int main() |
| chenlaoshi | 0:f9a53979b663 | 6 | { |
| chenlaoshi | 0:f9a53979b663 | 7 | int ledx ,cycle=4000; |
| chenlaoshi | 0:f9a53979b663 | 8 | while(1) |
| chenlaoshi | 0:f9a53979b663 | 9 | { |
| chenlaoshi | 0:f9a53979b663 | 10 | |
| chenlaoshi | 0:f9a53979b663 | 11 | for(ledx=0;ledx<cycle;ledx++) |
| chenlaoshi | 0:f9a53979b663 | 12 | { |
| chenlaoshi | 0:f9a53979b663 | 13 | myled = 1; // LED is ON |
| chenlaoshi | 0:f9a53979b663 | 14 | delay(ledx); |
| chenlaoshi | 0:f9a53979b663 | 15 | myled = 0; // LED is ON |
| chenlaoshi | 0:f9a53979b663 | 16 | delay(cycle-ledx); |
| chenlaoshi | 0:f9a53979b663 | 17 | } |
| chenlaoshi | 0:f9a53979b663 | 18 | |
| chenlaoshi | 0:f9a53979b663 | 19 | for(ledx=cycle;ledx>0;ledx--) |
| chenlaoshi | 0:f9a53979b663 | 20 | { |
| chenlaoshi | 0:f9a53979b663 | 21 | myled = 1; // LED is ON |
| chenlaoshi | 0:f9a53979b663 | 22 | delay(ledx); |
| chenlaoshi | 0:f9a53979b663 | 23 | myled = 0; // LED is ON |
| chenlaoshi | 0:f9a53979b663 | 24 | delay(cycle-ledx); |
| chenlaoshi | 0:f9a53979b663 | 25 | } |
| chenlaoshi | 0:f9a53979b663 | 26 | } |
| chenlaoshi | 0:f9a53979b663 | 27 | |
| chenlaoshi | 0:f9a53979b663 | 28 | } |
| chenlaoshi | 0:f9a53979b663 | 29 | void delay(long int i) |
| chenlaoshi | 0:f9a53979b663 | 30 | { |
| chenlaoshi | 0:f9a53979b663 | 31 | while(i--); |
| chenlaoshi | 0:f9a53979b663 | 32 | } |
| chenlaoshi | 0:f9a53979b663 | 33 |