![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AUP Xi'an Lab1
main.cpp@0:55b07f83af75, 2015-05-21 (annotated)
- Committer:
- gyth
- Date:
- Thu May 21 02:22:22 2015 +0000
- Revision:
- 0:55b07f83af75
AUP Xi'an Lab1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gyth | 0:55b07f83af75 | 1 | #include "mbed.h" |
gyth | 0:55b07f83af75 | 2 | |
gyth | 0:55b07f83af75 | 3 | DigitalOut red(D5); |
gyth | 0:55b07f83af75 | 4 | DigitalOut blue(D8); |
gyth | 0:55b07f83af75 | 5 | DigitalOut green(D9); |
gyth | 0:55b07f83af75 | 6 | AnalogIn analog_value(A0); |
gyth | 0:55b07f83af75 | 7 | int i; |
gyth | 0:55b07f83af75 | 8 | |
gyth | 0:55b07f83af75 | 9 | int main() { |
gyth | 0:55b07f83af75 | 10 | float meas; |
gyth | 0:55b07f83af75 | 11 | int i; |
gyth | 0:55b07f83af75 | 12 | |
gyth | 0:55b07f83af75 | 13 | while(1) { |
gyth | 0:55b07f83af75 | 14 | meas = analog_value.read(); |
gyth | 0:55b07f83af75 | 15 | |
gyth | 0:55b07f83af75 | 16 | i = (int)(meas * 8); |
gyth | 0:55b07f83af75 | 17 | red = i & 1; |
gyth | 0:55b07f83af75 | 18 | blue = i & 2; |
gyth | 0:55b07f83af75 | 19 | green = i & 4; |
gyth | 0:55b07f83af75 | 20 | wait(0.2); |
gyth | 0:55b07f83af75 | 21 | } |
gyth | 0:55b07f83af75 | 22 | } |