Video 2-
Code -
public void Pulse(int onTime, int offTime, bool onFirst, uint repeat) { bool doit = false; _worker = new Thread( delegate() { doit = doWork(onTime, offTime, onFirst, repeat); } ); _worker.Start(); } private bool doWork(int onTime, int offTime, bool onFirst, uint repeat) { if (onFirst) { for (uint c = 0; c < repeat; c++) { _pwmPort.SetDutyCycle((uint)Power); Thread.Sleep(onTime); _pwmPort.SetDutyCycle((uint)0); Thread.Sleep(offTime); } } else { for (uint c = 0; c < repeat; c++) { Thread.Sleep(offTime); _pwmPort.SetDutyCycle((uint)Power); Thread.Sleep(onTime); _pwmPort.SetDutyCycle((uint)0); } } return true; }