private static void LedPwm()
 {
     using (var board = new Arduino.Models.Arduino {
         Debug = true
     })
     {
         var led = new LedPwm(board, 9);
         led.Fade(255, 1.Second());
         Thread.Sleep(2.Seconds());
         led.Fade(0, 1.Second());
         led.Off();
     }
 }
Exemple #2
0
        public void Fade_with_high_value_should_fadeIn()
        {
            var       times       = 0;
            const int toIntensity = 255;

            _arduino.Setup(a => a.AnalogWrite(Pin, It.IsAny <int>())).Callback(() => { times++; }).Verifiable();
            _led.Fade(toIntensity);
            for (int i = 0; i < toIntensity - 1; i++)
            {
                _timer.Tick();
            }
            _led.Intensity.Should().Equal(toIntensity);
            times.Should().Equal(255);
        }
Exemple #3
0
        public void Fade_with_high_value_should_fadeIn()
        {
            var       times       = 0;
            const int toIntensity = 255;

            A.CallTo(() => _arduino.AnalogWrite(Pin, A <int> ._))
            .Invokes(() => { times++; });
            _led.Fade(toIntensity);
            for (var i = 0; i < toIntensity - 1; i++)
            {
                _timer.Tick();
            }
            _led.Intensity.ShouldEqual(toIntensity);
            times.ShouldEqual(255);
        }