Práctica 2 Ejercicio 4 A
Dependencies: mbed
main.cpp@0:f4f091492747, 2017-11-03 (annotated)
- Committer:
- anderibabe
- Date:
- Fri Nov 03 14:22:40 2017 +0000
- Revision:
- 0:f4f091492747
Pr?ctica 2 Ejercicio 4 A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
anderibabe | 0:f4f091492747 | 1 | #include "mbed.h" |
anderibabe | 0:f4f091492747 | 2 | |
anderibabe | 0:f4f091492747 | 3 | InterruptIn Sw1(PB_0); // Switch1 conectado al pin A3 |
anderibabe | 0:f4f091492747 | 4 | InterruptIn Sw2(PC_1); // Switch2 conectado al pin A4 |
anderibabe | 0:f4f091492747 | 5 | InterruptIn Sw3(PC_0); // Switch3 conectado al pin A5 |
anderibabe | 0:f4f091492747 | 6 | DigitalOut Led1(PB_3); // Led1 conectado al pin D3 |
anderibabe | 0:f4f091492747 | 7 | DigitalOut Led2(PB_5); // Led2 conectado al pin D4 |
anderibabe | 0:f4f091492747 | 8 | DigitalOut Led3(PB_4); // Led3 conectado al pin D5 |
anderibabe | 0:f4f091492747 | 9 | int myled; |
anderibabe | 0:f4f091492747 | 10 | void trigger1 () |
anderibabe | 0:f4f091492747 | 11 | { |
anderibabe | 0:f4f091492747 | 12 | Led1=myled; |
anderibabe | 0:f4f091492747 | 13 | myled=!myled; |
anderibabe | 0:f4f091492747 | 14 | } |
anderibabe | 0:f4f091492747 | 15 | |
anderibabe | 0:f4f091492747 | 16 | void trigger2 () |
anderibabe | 0:f4f091492747 | 17 | { |
anderibabe | 0:f4f091492747 | 18 | Led2=myled; |
anderibabe | 0:f4f091492747 | 19 | myled=!myled; |
anderibabe | 0:f4f091492747 | 20 | } |
anderibabe | 0:f4f091492747 | 21 | |
anderibabe | 0:f4f091492747 | 22 | void trigger3 () |
anderibabe | 0:f4f091492747 | 23 | { |
anderibabe | 0:f4f091492747 | 24 | Led3=myled; |
anderibabe | 0:f4f091492747 | 25 | myled=!myled; |
anderibabe | 0:f4f091492747 | 26 | } |
anderibabe | 0:f4f091492747 | 27 | |
anderibabe | 0:f4f091492747 | 28 | int main() |
anderibabe | 0:f4f091492747 | 29 | { |
anderibabe | 0:f4f091492747 | 30 | Sw1.rise(&trigger1); |
anderibabe | 0:f4f091492747 | 31 | Sw2.rise(&trigger2); |
anderibabe | 0:f4f091492747 | 32 | Sw3.rise(&trigger3); |
anderibabe | 0:f4f091492747 | 33 | while(1) { |
anderibabe | 0:f4f091492747 | 34 | sleep(); |
anderibabe | 0:f4f091492747 | 35 | } |
anderibabe | 0:f4f091492747 | 36 | } |