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.
Photo

Help with PWM and LEDs


  • Please log in to reply
3 replies to this topic

#1 FibreNet

FibreNet

    New Member

  • Members
  • Pip
  • 1 posts

Posted 01 November 2011 - 10:08 AM

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!

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 01 November 2011 - 10:11 AM

What about using two of these?

Hi FibreNet, and welcome to the Netduino community!

Those IC's are useful for that I think. I haven't used them myself yet but I know Nevyn recently posted something about those:
http://forums.netdui...940-pwm-driver/
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 01 November 2011 - 12:17 PM

Those IC's are useful for that I think. I haven't used them myself yet but I know Nevyn recently posted something about those:
http://forums.netdui...940-pwm-driver/

I have an update I'm preparing which will allow two or more of these to be cascaded. I currently have two of these working together using the grey scale data - dot correction and error detection need sorting out but it's looking OK so far.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#4 lesmondo

lesmondo

    Member

  • Members
  • PipPip
  • 24 posts

Posted 02 November 2011 - 12:18 PM

I'm currently playing with the PCA9622 - I2C 16 o/p 40V PWM LED driver. http://www.nxp.com/p...ol/PCA9622.html I'm still at the early prototype stage, so no code or hardware to post yet (the board is still at the fab house). Just thought you might be interested. Les




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.