thibault lottin
/
TP2_exo4
TP2_exo4
Exo4.cpp@0:544e5ff343ec, 2014-10-23 (annotated)
- Committer:
- mbedo
- Date:
- Thu Oct 23 12:14:30 2014 +0000
- Revision:
- 0:544e5ff343ec
TP2_exo4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedo | 0:544e5ff343ec | 1 | #include "mbed.h" |
mbedo | 0:544e5ff343ec | 2 | |
mbedo | 0:544e5ff343ec | 3 | AnalogIn ain(p19); |
mbedo | 0:544e5ff343ec | 4 | AnalogIn ain2(p20); |
mbedo | 0:544e5ff343ec | 5 | DigitalOut led(LED1); |
mbedo | 0:544e5ff343ec | 6 | DigitalOut led2(LED2); |
mbedo | 0:544e5ff343ec | 7 | DigitalOut led3(LED3); |
mbedo | 0:544e5ff343ec | 8 | DigitalOut led4(LED4); |
mbedo | 0:544e5ff343ec | 9 | |
mbedo | 0:544e5ff343ec | 10 | |
mbedo | 0:544e5ff343ec | 11 | int main() { |
mbedo | 0:544e5ff343ec | 12 | while (1){ |
mbedo | 0:544e5ff343ec | 13 | if(ain > 0.3) { |
mbedo | 0:544e5ff343ec | 14 | led = 1; |
mbedo | 0:544e5ff343ec | 15 | wait(0.25); |
mbedo | 0:544e5ff343ec | 16 | } else { |
mbedo | 0:544e5ff343ec | 17 | led = 0; |
mbedo | 0:544e5ff343ec | 18 | } |
mbedo | 0:544e5ff343ec | 19 | if(ain > 0.25) { |
mbedo | 0:544e5ff343ec | 20 | led2 = 1; |
mbedo | 0:544e5ff343ec | 21 | wait(0.25); |
mbedo | 0:544e5ff343ec | 22 | } else { |
mbedo | 0:544e5ff343ec | 23 | led2 = 0; |
mbedo | 0:544e5ff343ec | 24 | } |
mbedo | 0:544e5ff343ec | 25 | if(ain > 0.2) { |
mbedo | 0:544e5ff343ec | 26 | led3 = 1; |
mbedo | 0:544e5ff343ec | 27 | wait(0.25); |
mbedo | 0:544e5ff343ec | 28 | } else { |
mbedo | 0:544e5ff343ec | 29 | led3 = 0; |
mbedo | 0:544e5ff343ec | 30 | } |
mbedo | 0:544e5ff343ec | 31 | if(ain > 0.15) { |
mbedo | 0:544e5ff343ec | 32 | led4 = 1; |
mbedo | 0:544e5ff343ec | 33 | wait(0.25); |
mbedo | 0:544e5ff343ec | 34 | } else { |
mbedo | 0:544e5ff343ec | 35 | led4 = 0; |
mbedo | 0:544e5ff343ec | 36 | } |
mbedo | 0:544e5ff343ec | 37 | } |
mbedo | 0:544e5ff343ec | 38 | } |
mbedo | 0:544e5ff343ec | 39 |