MII1SistElec
/
PR2EJ7
practica2ejercicio7
main.cpp
- Committer:
- carlospomar
- Date:
- 2017-11-06
- Revision:
- 1:ee5228330793
- Parent:
- 0:1272b81992d4
- Child:
- 2:150c7630f878
File content as of revision 1:ee5228330793:
#include "mbed.h" #include "rtos.h" 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 void blink1(void const *argument) { while (1) { Led1 = !Led1; //cambiar el Led de estado Thread::wait(1000); //tiempo de espera para cambiar el led1 de estado } } void blink2(void const *argument) { while (1) { Led2 = !Led2; //cambiar el Led de estado Thread::wait(1200); //tiempo de espera para cambiar el led2 de estado } } void blink3(void const *argument) { while (1) { Led3 = !Led3; //cambiar el Led de estado Thread::wait(1500); //tiempo de espera para cambiar el led3 de estado } } int main() { Thread thread1(blink1, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); //forma apropiada de llamar a los Thread Thread thread2(blink2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); Thread thread3(blink3, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); while (true) { //código para que el programa no acabe y los Thread sigan ejecutándose Thread::wait(500); } }