practica2ejercicio8
Fork of PR2EJ8 by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 DigitalIn Sw1(PB_0); // Switch1 conectado al pin A3 00005 DigitalIn Sw2(PC_1); // Switch2 conectado al pin A4 00006 DigitalIn Sw3(PC_0); // Switch3 conectado al pin A5 00007 DigitalOut Led1(PB_3); // Led1 conectado al pin D3 00008 DigitalOut Led2(PB_5); // Led2 conectado al pin D4 00009 DigitalOut Led3(PB_4); // Led3 conectado al pin D5 00010 int estado1,estado2,estado3; 00011 00012 void pulsador1(void const *argument) 00013 { 00014 while (1) { 00015 if (estado1&&(Sw1)) { //verifica el estado del pulsador 00016 Led1 = !Sw1; //cambiar el Led de estado 00017 00018 } 00019 estado1=Sw1; 00020 Thread::wait(200); //tiempo de espera 00021 } 00022 } 00023 00024 void pulsador2(void const *argument) 00025 { 00026 while (1) { 00027 if (estado2&&(Sw2)) { //verifica el estado del pulsador 00028 Led2 = !Sw2; //cambiar el Led de estado 00029 00030 } 00031 estado2=Sw2; 00032 Thread::wait(200); //tiempo de espera 00033 } 00034 } 00035 00036 void pulsador3(void const *argument) 00037 { 00038 while (1) { 00039 if (estado3&&(Sw3)) { //verifica el estado del pulsador 00040 Led3 = !Sw3; //cambiar el Led de estado 00041 00042 } 00043 estado3=Sw3; 00044 Thread::wait(200); //tiempo de espera 00045 } 00046 } 00047 00048 00049 int main() 00050 { 00051 Thread thread1(pulsador1, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); 00052 Thread thread2(pulsador2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); 00053 Thread thread3(pulsador3, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); 00054 while (true) { 00055 Thread::wait(500); 00056 } 00057 }
Generated on Fri Jul 29 2022 03:23:07 by
1.7.2
