J&W / Mbed 2 deprecated Rejestrator

Dependencies:   mbed Rejestrator

Dependents:   Rejestrator

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WaitForSwitch.cpp Source File

WaitForSwitch.cpp

00001 #include "WaitForSwitch.h"
00002 
00003 void WaitForSwitch(DigitalIn Switch, PwmOut led)
00004 {
00005     float Pwm = 0;
00006     while (Switch.read() != 0)
00007     {
00008         led = Pwm;
00009         Pwm += 0.01;
00010         if (Pwm > 1) Pwm = 0;
00011         rtos::Thread::wait(10);
00012     }
00013     while (Switch.read() == 0)
00014     {
00015         led = Pwm;
00016         Pwm -= 0.01;
00017         if (Pwm < 0) Pwm = 1;
00018         rtos::Thread::wait(10);
00019     }
00020     led = 0;
00021 }