Akira Kashihara
/
Challenge2_easy
work shop sample
main.cpp
- Committer:
- AkiraK
- Date:
- 2012-10-24
- Revision:
- 0:946287229e5e
File content as of revision 0:946287229e5e:
#include "mbed.h" DigitalOut myleds[] = {LED1, LED2, LED3, LED4}; AnalogIn illu(p15); int main() { while(true) { float lx = illu * 3.3 / 3 * 1000; printf("%4.2f\n", lx); if( 250 > lx && lx > 0) { myleds[0] = 1; for(int i = 1; i <4; i++) { myleds[i] = 0; } }else if(500 > lx && lx >= 250) { myleds[0] = 1; myleds[1] = 1; myleds[2] = 0; myleds[3] = 0; }else if(750 > lx && lx >= 500) { for(int x = 0; x < 3; x++) { myleds[x] = 1; } myleds[3] = 0; }else if(lx >= 750) { for(int y = 0; y < 4; y++) { myleds[y] = 1; } } } }