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:d257a5dacc0b, 2016-09-04 (annotated)
- Committer:
- yu10078999
- Date:
- Sun Sep 04 05:15:32 2016 +0000
- Revision:
- 1:d257a5dacc0b
- Parent:
- 0:93daf3a92680
2
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yu10078999 | 0:93daf3a92680 | 1 | #include "mbed.h" |
| yu10078999 | 0:93daf3a92680 | 2 | DigitalOut led(D2); |
| yu10078999 | 0:93daf3a92680 | 3 | AnalogIn CDS(A0); |
| yu10078999 | 0:93daf3a92680 | 4 | |
| yu10078999 | 0:93daf3a92680 | 5 | int main() { |
| yu10078999 | 0:93daf3a92680 | 6 | float val; |
| yu10078999 | 0:93daf3a92680 | 7 | while(1) { |
| yu10078999 | 0:93daf3a92680 | 8 | val=CDS.read(); |
| yu10078999 | 0:93daf3a92680 | 9 | printf("%f\n",val); |
| yu10078999 | 0:93daf3a92680 | 10 | wait(0.2); |
| yu10078999 | 1:d257a5dacc0b | 11 | if(val<0.4f){ |
| yu10078999 | 1:d257a5dacc0b | 12 | led=0; |
| yu10078999 | 0:93daf3a92680 | 13 | } |
| yu10078999 | 1:d257a5dacc0b | 14 | else if(val>=0.4f){ |
| yu10078999 | 1:d257a5dacc0b | 15 | led=1; |
| yu10078999 | 0:93daf3a92680 | 16 | } |
| yu10078999 | 0:93daf3a92680 | 17 | } |
| yu10078999 | 0:93daf3a92680 | 18 | } |