Main Site Documentation

Fade-in and -out on onboard RGB-led (Mountaineer Ethernet board)


#1

Hi,

I want to fade-in and -out on onboard RGB-led on Mountaineer Ethernet board. But I can’t. I know C# programming, but novice in programming on NetMF.

I wrote the code, but the LED does not fade:


var pwm = new PWM(OnboardIO.PwmBlue, 10000, 0.1, false);

var i = 0.0;
while (true)
{
    pwm.DutyCycle = i;
    pwm.Start();

    i += 0.1;

    Thread.Sleep(100);
}

Thanks for your help


#2

Your duty cycle will exceed 100% in 100 seconds .

You also need to reduce the cycle


#3

I agree, but within 10 seconds, the LED need to fade in?


#4

Are you saying the LED does not go from dark to fully lighted?

I checked the PWM class documentation and saw that 100% duty cycle is represented by a 1.0 not 100.0.

With your code the LED would go to full in a second.

Are you seeing an exception in the output window of visual studio?

Are you sure the onboard LEDs are attached to PWM ports? In the datasheet and schematic I don’t see it.


#5

Yes. The onboard LED does not lighted up. If I use simple port (without PWM) LED has lighted.

No

In the http://www.mountaineer.org/app/download/6083970675/Mountaineer.Netmf.Hardware.pdf on the page 12. There are the code:


/// <summary>
/// on-board LED Blue, PE14/PWM_CH7
/// </summary>
public const Cpu.PWMChannel PwmBlue = Cpu.PWMChannel.PWM_7;

So… I think, that on-board led has PWM. Or I’m wrong?


#6

try moving the start method outside the while loop


#7

it’s working! Mea culpa. In the code above, I was initializing:

var bl = new OutputPort(OnboardIO.LedBlue, false)

I do not consider that the port can only be opened in one of two modes (simple and PWM). I just commented the line with the “new OutputPort” and it worked.

Mike, thanks for your help!


#8

Consider to add some code to fade in and fade out the led to this project: