Lei Lei
/
AUP_Lab1_GPIO
AUP_Lab1_GPIO
Fork of Lab1_GPIO by
Revision 1:e93b0f5db57f, committed 2015-09-17
- Comitter:
- BrentLei
- Date:
- Thu Sep 17 05:44:49 2015 +0000
- Parent:
- 0:55b07f83af75
- Commit message:
- Logic simplified
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 55b07f83af75 -r e93b0f5db57f main.cpp --- a/main.cpp Thu May 21 02:22:22 2015 +0000 +++ b/main.cpp Thu Sep 17 05:44:49 2015 +0000 @@ -4,19 +4,22 @@ DigitalOut blue(D8); DigitalOut green(D9); AnalogIn analog_value(A0); -int i; -int main() { - float meas; - int i; +int main() +{ + double meas; - while(1) { + while(1) + { meas = analog_value.read(); - i = (int)(meas * 8); - red = i & 1; - blue = i & 2; - green = i & 4; - wait(0.2); + if (meas < 0.3) + red = 0, blue = 1, green = 1; + else if (meas < 0.7) + red = 1, blue = 0, green = 1; + else + red = 1, blue = 1, green = 0; + + wait(0.1); } }