Lab02-1
Dependencies: mbed
Revision 0:5c28f597bf8f, committed 2015-10-13
- Comitter:
- kantapon501
- Date:
- Tue Oct 13 07:38:48 2015 +0000
- Commit message:
- Lab02-1
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 Tue Oct 13 07:38:48 2015 +0000 @@ -0,0 +1,121 @@ +#include "mbed.h" + +DigitalOut Out1(D13); +DigitalOut Out2(D12); +DigitalOut Out3(D11); +DigitalOut Out4(D10); +DigitalOut Out5(D9); +DigitalOut Out6(D8); +DigitalOut Out7(D7); +DigitalOut Out8(D6); +AnalogIn Anain(A1); + +int main() +{ + while(1) + { + double Value = Anain.read(); + if(Value <0.0825) + { + Out1 = 0; + Out2 = 0; + Out3 = 0; + Out4 = 0; + Out5 = 0; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.0825 && Value < 0.165) + { + Out1 = 1; + Out2 = 0; + Out3 = 0; + Out4 = 0; + Out5 = 0; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.165 && Value < 0.2475) + { + Out1 = 1; + Out2 = 1; + Out3 = 0; + Out4 = 0; + Out5 = 0; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.2475 && Value < 0.33) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 0; + Out5 = 0; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.33 && Value < 0.4125) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 1; + Out5 = 0; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.4125 && Value < 0.495) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 1; + Out5 = 1; + Out6 = 0; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.495 && Value < 0.5775) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 1; + Out5 = 1; + Out6 = 1; + Out7 = 0; + Out8 = 0; + } + else if(Value >= 0.5775 && Value < 0.66) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 1; + Out5 = 1; + Out6 = 1; + Out7 = 1; + Out8 = 0; + } + else if(Value >= 0.66) + { + Out1 = 1; + Out2 = 1; + Out3 = 1; + Out4 = 1; + Out5 = 1; + Out6 = 1; + Out7 = 1; + Out8 = 1; + } + } + + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 13 07:38:48 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file