Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PR2EJ8 by
Diff: main.cpp
- Revision:
- 1:c86864e0f17a
- Parent:
- 0:a995f1b1f71c
- Child:
- 2:ff26484331d3
--- a/main.cpp Mon Nov 06 17:20:46 2017 +0000 +++ b/main.cpp Wed Nov 08 10:33:12 2017 +0000 @@ -7,34 +7,41 @@ DigitalOut Led1(PB_3); // Led1 conectado al pin D3 DigitalOut Led2(PB_5); // Led2 conectado al pin D4 DigitalOut Led3(PB_4); // Led3 conectado al pin D5 +int estado1,estado2,estado3 -void estado1(void const *argument) +void pulsador1(void const *argument) { while (1) { - if (!Sw1) { //verifica el estado del pulsador + if (estado1&&(Sw1)) { //verifica el estado del pulsador Led1 = !Sw1; //cambiar el Led de estado - Thread::wait(200); //tiempo de espera + } + estado1=Sw1; + Thread::wait(200); //tiempo de espera } } -void estado2(void const *argument) +void pulsador2(void const *argument) { - while (1) { - if (!Sw2) { //verifica el estado del pulsador + while (1) { + if (estado2&&(Sw2)) { //verifica el estado del pulsador Led2 = !Sw2; //cambiar el Led de estado - Thread::wait(200); //tiempo de espera + } + estado2=Sw2; + Thread::wait(200); //tiempo de espera } } -void estado3(void const *argument) +void pulsador3(void const *argument) { while (1) { - if (!Sw3) { //verifica el estado del pulsador - Led3 = !Sw3; //cambiar el Led de estado - Thread::wait(200); //tiempo de espera + if (estado3&&(Sw3)) { //verifica el estado del pulsador + Led3 = !Sw3; //cambiar el Led de estado + } + estado3=Sw3; + Thread::wait(200); //tiempo de espera } } @@ -42,8 +49,8 @@ int main() { Thread thread1(estado1, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); - Thread thread2(estado2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); - Thread thread3(estado3, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + Thread thread2(estado2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + Thread thread3(estado3, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); while (true) { Thread::wait(500); }