Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

FibreNet's Content

There have been 1 items by FibreNet (Search limited from 04-July 23)


By content type

See this member's

Sort by                Order  

#20039 Help with PWM and LEDs

Posted by FibreNet on 01 November 2011 - 10:08 AM in Netduino Plus 2 (and Netduino Plus 1)

Hey everyone!

I'm working on a little project which involves controlling 10 RGB LEDs using my Netduino Plus, and I've run into a slight problem.

I want to be able to have all 10 RGB LEDs on maximum brightness simultaneously, but each with its own PWM values for red, green and blue.

I have tried looping through all 10 LEDs really quickly and turning each one on at a time with its own PWM values set, but the LEDs aren't at maximum brightness. This is a test program I have tried:

public static void Main()
{
	PWM red = new PWM(Pins.GPIO_PIN_D5);
	PWM green = new PWM(Pins.GPIO_PIN_D6);
	PWM blue = new PWM(Pins.GPIO_PIN_D9);

	OutputPort[] leds = new OutputPort[10];
	leds[0] = new OutputPort(Pins.GPIO_PIN_D2, false);
	leds[1] = new OutputPort(Pins.GPIO_PIN_D3, false);
	leds[2] = new OutputPort(Pins.GPIO_PIN_D4, false);
	leds[3] = new OutputPort(Pins.GPIO_PIN_D7, false);
	leds[4] = new OutputPort(Pins.GPIO_PIN_D8, false);
	leds[5] = new OutputPort(Pins.GPIO_PIN_D10, false);
	leds[6] = new OutputPort(Pins.GPIO_PIN_D11, false);
	leds[7] = new OutputPort(Pins.GPIO_PIN_D12, false);
	leds[8] = new OutputPort(Pins.GPIO_PIN_D13, false);
	leds[9] = new OutputPort(Pins.GPIO_PIN_A0, false);

	while (true)
	{
		for (int i = 0; i < leds.Length; i++)
		{
			leds[i].Write(true);
			if (i % 2 == 1)
			{
				red.SetDutyCycle(100);
				red.SetDutyCycle(0);
			}
			else
			{
				green.SetDutyCycle(100);
				green.SetDutyCycle(0);
			}
			leds[i].Write(false);
		}
	}
}

What's the easiest way to accomplish this? (10 RGB LEDs, on simultaneously, each with its own PWM values for red, green and blue)

What about using two of these?

Thanks!




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.