public static void DisposeAll() { AnalogInput.DisposeActive(); DigitalInput.DisposeActive(); DigitalInterrupt.DisposeActive(); DigitalOutput.DisposeActive(); PwmOutput.DisposeActive(); }
// -------------------------------- Sensori -------------------------------- // private void InitSensors() { Mainboard.SetDebugLED(true); Gadgeteer.Socket socket = Gadgeteer.Socket.GetSocket(8, true, null, null); buzzer = new PWM(Cpu.PWMChannel.PWM_4, 1000, 0.5, false); buzzer.Stop(); orizzontal_mov = extender.CreatePwmOutput(Gadgeteer.Socket.Pin.Seven); vertical_mov = extender.CreatePwmOutput(Gadgeteer.Socket.Pin.Nine); current_orizzontal_pos = 0.075; current_vertical_pos = 0.075; orizzontal_mov.Set(50, current_orizzontal_pos); Thread.Sleep(2000); vertical_mov.Set(50, current_vertical_pos); }
public Lighting(Extender extender, GT.Socket.Pin pin, int frequency, float lowLightDutyCycle, float overheadDutyCycle, float nightDutyCycle) { this.extender = extender; this.frequency = frequency; this.lowLight = lowLightDutyCycle; this.overhead = overheadDutyCycle; this.night = nightDutyCycle; //asign the pin for pwm PwmOutput pwm = extender.CreatePwmOutput(pin); //thread that loops changing the light output per time of day Thread thread = new Thread(() => PwmThread(pwm)); thread.Start(); }
private void PwmThread(PwmOutput pwm) { do { float dutyCycle = GetCurrentDutyCycle(); try { pwm.Set(this.frequency, dutyCycle); } catch { Debug.Print("Unable to set pwm"); } Thread.Sleep(1000); //string thread = Thread.CurrentThread.ManagedThreadId.ToString(); //Debug.Print("dutyCycle of " + thread + " is " + dutyCycle + " at " + DateTime.Now.TimeOfDay.ToString()); } while (true); }