ldr blinky
Dependencies: mbed
main.cpp@1:799a74dde023, 2014-06-19 (annotated)
- Committer:
- 08DyeG
- Date:
- Thu Jun 19 13:31:49 2014 +0000
- Revision:
- 1:799a74dde023
- Parent:
- 0:1d3ca434d486
2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
08DyeG | 0:1d3ca434d486 | 1 | #include "mbed.h" |
08DyeG | 0:1d3ca434d486 | 2 | |
08DyeG | 0:1d3ca434d486 | 3 | DigitalOut r(PTC2); |
08DyeG | 0:1d3ca434d486 | 4 | DigitalOut g(PTC1); |
08DyeG | 0:1d3ca434d486 | 5 | AnalogIn ldr(A3); |
08DyeG | 0:1d3ca434d486 | 6 | |
08DyeG | 0:1d3ca434d486 | 7 | int main(){ |
08DyeG | 0:1d3ca434d486 | 8 | while(1){ |
08DyeG | 1:799a74dde023 | 9 | if(ldr>0.51){ |
08DyeG | 0:1d3ca434d486 | 10 | g=1; |
08DyeG | 0:1d3ca434d486 | 11 | r=0; |
08DyeG | 0:1d3ca434d486 | 12 | } |
08DyeG | 0:1d3ca434d486 | 13 | else if(ldr<0.50){ |
08DyeG | 0:1d3ca434d486 | 14 | g=0; |
08DyeG | 0:1d3ca434d486 | 15 | r=1; |
08DyeG | 0:1d3ca434d486 | 16 | } |
08DyeG | 0:1d3ca434d486 | 17 | } |
08DyeG | 0:1d3ca434d486 | 18 | } |