Alyson Castiblanco
/
PRUEBASERIAL1
Código de prueba de leds desde Matlab. Pendiente ADC y datos desde tarjeta a Matlab
main.cpp@0:ff26bbb6038a, 2018-10-26 (annotated)
- Committer:
- acastiblancoc
- Date:
- Fri Oct 26 22:15:36 2018 +0000
- Revision:
- 0:ff26bbb6038a
Codigo de prueba
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
acastiblancoc | 0:ff26bbb6038a | 1 | #include "mbed.h" |
acastiblancoc | 0:ff26bbb6038a | 2 | |
acastiblancoc | 0:ff26bbb6038a | 3 | Serial pc(SERIAL_TX, SERIAL_RX); |
acastiblancoc | 0:ff26bbb6038a | 4 | DigitalOut led(D2); |
acastiblancoc | 0:ff26bbb6038a | 5 | DigitalOut led1(D3); |
acastiblancoc | 0:ff26bbb6038a | 6 | DigitalOut led2(D4); |
acastiblancoc | 0:ff26bbb6038a | 7 | AnalogIn pot(A0); |
acastiblancoc | 0:ff26bbb6038a | 8 | int main() |
acastiblancoc | 0:ff26bbb6038a | 9 | { |
acastiblancoc | 0:ff26bbb6038a | 10 | pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); |
acastiblancoc | 0:ff26bbb6038a | 11 | |
acastiblancoc | 0:ff26bbb6038a | 12 | while(1) { |
acastiblancoc | 0:ff26bbb6038a | 13 | char c = pc.getc(); // Read hyperterminal |
acastiblancoc | 0:ff26bbb6038a | 14 | if (c == '0') { |
acastiblancoc | 0:ff26bbb6038a | 15 | led = 1; |
acastiblancoc | 0:ff26bbb6038a | 16 | led1=0; |
acastiblancoc | 0:ff26bbb6038a | 17 | led2=0; |
acastiblancoc | 0:ff26bbb6038a | 18 | } |
acastiblancoc | 0:ff26bbb6038a | 19 | if (c == '2') { |
acastiblancoc | 0:ff26bbb6038a | 20 | led = 0; |
acastiblancoc | 0:ff26bbb6038a | 21 | led1=1; |
acastiblancoc | 0:ff26bbb6038a | 22 | led2=0; |
acastiblancoc | 0:ff26bbb6038a | 23 | } |
acastiblancoc | 0:ff26bbb6038a | 24 | led2.write(c); |
acastiblancoc | 0:ff26bbb6038a | 25 | float T=pot.read(); |
acastiblancoc | 0:ff26bbb6038a | 26 | |
acastiblancoc | 0:ff26bbb6038a | 27 | } |
acastiblancoc | 0:ff26bbb6038a | 28 | } |
acastiblancoc | 0:ff26bbb6038a | 29 |