eiei
Dependencies: mbed
main.cpp@0:363b043d28bd, 2015-10-14 (annotated)
- Committer:
- Peeraya
- Date:
- Wed Oct 14 04:44:25 2015 +0000
- Revision:
- 0:363b043d28bd
VR
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Peeraya | 0:363b043d28bd | 1 | #include "mbed.h" |
Peeraya | 0:363b043d28bd | 2 | |
Peeraya | 0:363b043d28bd | 3 | AnalogIn analog_value(A1); |
Peeraya | 0:363b043d28bd | 4 | |
Peeraya | 0:363b043d28bd | 5 | DigitalOut myled1(D13); |
Peeraya | 0:363b043d28bd | 6 | DigitalOut myled2(D12); |
Peeraya | 0:363b043d28bd | 7 | DigitalOut myled3(D11); |
Peeraya | 0:363b043d28bd | 8 | DigitalOut myled4(D10); |
Peeraya | 0:363b043d28bd | 9 | DigitalOut myled5(D9); |
Peeraya | 0:363b043d28bd | 10 | DigitalOut myled6(D8); |
Peeraya | 0:363b043d28bd | 11 | DigitalOut myled7(D7); |
Peeraya | 0:363b043d28bd | 12 | DigitalOut myled8(D4); |
Peeraya | 0:363b043d28bd | 13 | |
Peeraya | 0:363b043d28bd | 14 | |
Peeraya | 0:363b043d28bd | 15 | int main() { |
Peeraya | 0:363b043d28bd | 16 | float meas; |
Peeraya | 0:363b043d28bd | 17 | |
Peeraya | 0:363b043d28bd | 18 | while(1) { |
Peeraya | 0:363b043d28bd | 19 | meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
Peeraya | 0:363b043d28bd | 20 | if(meas<0.0625){myled1=0;myled2=0;myled3=0;myled4=0;myled5=0;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 21 | else if(meas<0.1875){myled1=1;myled2=0;myled3=0;myled4=0;myled5=0;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 22 | else if(meas<0.3125){myled1=1;myled2=1;myled3=0;myled4=0;myled5=0;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 23 | else if(meas<0.4375){myled1=1;myled2=1;myled3=1;myled4=0;myled5=0;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 24 | else if(meas<0.5625){myled1=1;myled2=1;myled3=1;myled4=1;myled5=0;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 25 | else if(meas<0.6875){myled1=1;myled2=1;myled3=1;myled4=1;myled5=1;myled6=0;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 26 | else if(meas<0.8125){myled1=1;myled2=1;myled3=1;myled4=1;myled5=1;myled6=1;myled7=0;myled8=0;} |
Peeraya | 0:363b043d28bd | 27 | else if(meas<0.9375){myled1=1;myled2=1;myled3=1;myled4=1;myled5=1;myled6=1;myled7=1;myled8=0;} |
Peeraya | 0:363b043d28bd | 28 | else{myled1=1;myled2=1;myled3=1;myled4=1;myled5=1;myled6=1;myled7=1;myled8=1;} |
Peeraya | 0:363b043d28bd | 29 | |
Peeraya | 0:363b043d28bd | 30 | } |
Peeraya | 0:363b043d28bd | 31 | } |
Peeraya | 0:363b043d28bd | 32 |