P3_9

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main_9.cpp Source File

main_9.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 DigitalIn myswitch1(A5);
00005 DigitalOut myled1(D4);
00006 int estadoled1=1;
00007 
00008 void thread_led1(void const *argument)
00009 {
00010     while (1) {
00011         Thread::signal_wait(0x1);
00012         myled1 = !myled1;
00013 
00014     }
00015 }
00016 
00017 int main()
00018 {
00019     Thread thread(thread_led1, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
00020 
00021     while (true) {
00022         if (estadoled1&&(!myswitch1)) {
00023             thread.signal_set(0x1);
00024             //thread.start(thread_led1);
00025 
00026         }
00027         estadoled1=myswitch1;
00028         Thread::wait(200);
00029     }
00030 }