コード例 #1
0
ファイル: Program.cs プロジェクト: TjWheeler/dotnet-iot-demos
        static void PWMFanSimpleExample()
        {
            Console.WriteLine("Starting PWM Controller - Simple Demo");
            using (var controller = new PwmController())
            {
                double dutyCycle = 100;
                var    chip      = 0;
                var    channel   = 0;
                var    hertz     = 25;
                controller.OpenChannel(chip, channel);
                controller.StartWriting(chip, channel, hertz, dutyCycle);
                Console.WriteLine("Duty cycle " + dutyCycle);
                Task.Delay(new TimeSpan(0, 0, 10)).Wait(); //10 second wait to give fan time to power up
                ReadTachometer();

                dutyCycle = 70;
                controller.ChangeDutyCycle(chip, channel, dutyCycle);
                Console.WriteLine("Duty cycle " + dutyCycle);
                Task.Delay(new TimeSpan(0, 0, 2)).Wait(); //2 second wait
                ReadTachometer();

                dutyCycle = 30;
                controller.ChangeDutyCycle(chip, channel, dutyCycle);
                Console.WriteLine("Duty cycle " + dutyCycle);
                Task.Delay(new TimeSpan(0, 0, 2)).Wait(); //2 second wait
                ReadTachometer();

                controller.ChangeDutyCycle(chip, channel, 0); //
                controller.StopWriting(chip, channel);
                controller.CloseChannel(chip, channel);
                Console.WriteLine("Finished - Simple Demo");
            }
        }
コード例 #2
0
 public void Dispose()
 {
     _pwmController.StopWriting(_servoPin, _pwmChannel);
     _pwmController.CloseChannel(_servoPin, _pwmChannel);
 }
コード例 #3
0
 /// <summary>
 /// Stop playing tone.
 /// </summary>
 public void StopPlaying()
 {
     _pwmController.StopWriting(_buzzerPin, _pwmChannel);
 }