Akira Kashihara
/
Challenge2_easy
work shop sample
Revision 0:946287229e5e, committed 2012-10-24
- Comitter:
- AkiraK
- Date:
- Wed Oct 24 08:29:30 2012 +0000
- Commit message:
- Challenge2_easy;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 24 08:29:30 2012 +0000 @@ -0,0 +1,39 @@ +#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; + } + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 24 08:29:30 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc \ No newline at end of file