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:597324ae35ab, 2015-06-01 (annotated)
- Committer:
- mindstorm
- Date:
- Mon Jun 01 20:16:22 2015 +0000
- Revision:
- 0:597324ae35ab
nowa wersja
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mindstorm | 0:597324ae35ab | 1 | // Toggle a LED |
mindstorm | 0:597324ae35ab | 2 | #include "mbed.h" |
mindstorm | 0:597324ae35ab | 3 | |
mindstorm | 0:597324ae35ab | 4 | DigitalOut led1(PB_1); |
mindstorm | 0:597324ae35ab | 5 | DigitalOut led2(PB_2); |
mindstorm | 0:597324ae35ab | 6 | AnalogIn potencjometr(PB_0); |
mindstorm | 0:597324ae35ab | 7 | float x ; |
mindstorm | 0:597324ae35ab | 8 | int main() { |
mindstorm | 0:597324ae35ab | 9 | led2=1; |
mindstorm | 0:597324ae35ab | 10 | while(1) { |
mindstorm | 0:597324ae35ab | 11 | x=potencjometr.read(); |
mindstorm | 0:597324ae35ab | 12 | if (x>=0.5) |
mindstorm | 0:597324ae35ab | 13 | { |
mindstorm | 0:597324ae35ab | 14 | led1 = !led1; |
mindstorm | 0:597324ae35ab | 15 | wait(0.05); |
mindstorm | 0:597324ae35ab | 16 | } |
mindstorm | 0:597324ae35ab | 17 | if (x<0.5) |
mindstorm | 0:597324ae35ab | 18 | { |
mindstorm | 0:597324ae35ab | 19 | led1 = !led1; |
mindstorm | 0:597324ae35ab | 20 | wait(0.3); |
mindstorm | 0:597324ae35ab | 21 | } |
mindstorm | 0:597324ae35ab | 22 | |
mindstorm | 0:597324ae35ab | 23 | } |
mindstorm | 0:597324ae35ab | 24 | } |