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@1:63e28be79637, 2015-08-03 (annotated)
- Committer:
- youhinclark
- Date:
- Mon Aug 03 10:35:21 2015 +0000
- Revision:
- 1:63e28be79637
- Parent:
- 0:d86587ed9b1c
Touch
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hasimo | 0:d86587ed9b1c | 1 | #include "mbed.h" |
| hasimo | 0:d86587ed9b1c | 2 | #include "TextLCD.h" |
| hasimo | 0:d86587ed9b1c | 3 | |
| hasimo | 0:d86587ed9b1c | 4 | TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 |
| hasimo | 0:d86587ed9b1c | 5 | AnalogIn ain(p15); |
| youhinclark | 1:63e28be79637 | 6 | DigitalOut myled1(LED1); |
| youhinclark | 1:63e28be79637 | 7 | DigitalOut myled2(LED2); |
| youhinclark | 1:63e28be79637 | 8 | DigitalOut myled3(LED3); |
| youhinclark | 1:63e28be79637 | 9 | DigitalOut myled4(LED4); |
| hasimo | 0:d86587ed9b1c | 10 | int main() { |
| youhinclark | 1:63e28be79637 | 11 | float abc=0; |
| hasimo | 0:d86587ed9b1c | 12 | |
| hasimo | 0:d86587ed9b1c | 13 | while (1){ |
| youhinclark | 1:63e28be79637 | 14 | abc=ain.read(); |
| hasimo | 0:d86587ed9b1c | 15 | lcd.locate(0,0); |
| youhinclark | 1:63e28be79637 | 16 | abc*=10; |
| youhinclark | 1:63e28be79637 | 17 | lcd.printf("%8.3f cm\n", abc); |
| youhinclark | 1:63e28be79637 | 18 | if((int)(abc)%4==0) myled1=1; |
| youhinclark | 1:63e28be79637 | 19 | else myled1=0; |
| youhinclark | 1:63e28be79637 | 20 | if((int)(abc)%4==1) myled2=1; |
| youhinclark | 1:63e28be79637 | 21 | else myled2=0; |
| youhinclark | 1:63e28be79637 | 22 | if((int)(abc)%4==2) myled3=1; |
| youhinclark | 1:63e28be79637 | 23 | else myled3=0; |
| youhinclark | 1:63e28be79637 | 24 | if((int)(abc)%4==3) myled4=1; |
| youhinclark | 1:63e28be79637 | 25 | else myled4=0; |
| hasimo | 0:d86587ed9b1c | 26 | wait(0.05); // 20Hz update rate |
| hasimo | 0:d86587ed9b1c | 27 | } |
| hasimo | 0:d86587ed9b1c | 28 | } |