Atope / Mbed 2 deprecated PR30_8

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

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  
00011 void estado1(void const *argument)
00012 {
00013     while (1) {
00014         if (!Sw1) {              //verifica el estado del pulsador 
00015             Led1 = !Sw1;       //cambiar el Led de estado
00016             Thread::wait(200);  //tiempo de espera 
00017         }
00018     }
00019 }
00020  
00021 void estado2(void const *argument)
00022 {
00023     while (1) {
00024         if (!Sw2) {              //verifica el estado del pulsador 
00025             Led2 = !Sw2;       //cambiar el Led de estado
00026             Thread::wait(200);  //tiempo de espera 
00027         }
00028     }
00029 }
00030  
00031 void estado3(void const *argument)
00032 {
00033     while (1) {
00034         if (!Sw3) {              //verifica el estado del pulsador 
00035             Led3 = !Sw3;       //cambiar el Led de estado
00036             Thread::wait(200);  //tiempo de espera 
00037         }
00038     }
00039 }
00040  
00041  
00042 int main()
00043 {
00044     Thread thread1(estado1, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
00045     Thread thread2(estado2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);    
00046     Thread thread3(estado3, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);    
00047     while (true) {
00048         Thread::wait(500);
00049     }
00050 }