Jorge Ramírezbryan costanichAdrian Stevens
Published © Apache-2.0

Show Rainbow Colors with an RGB LED and Netduino

Learn how you can control a RGB LED with Netduino. Foundation, a powerful platform to build connected things quickly and easily with NETMF.

BeginnerFull instructions provided1 hour637

Things used in this project

Story

Read more

Schematics

Common Cathode RGB LED circuit

Common Anode RGB LED Circuit

Code

RgbPwmLed

C#
Code used for this project
using Microsoft.SPOT;
using Netduino.Foundation;
using System.Threading;
using N = SecretLabs.NETMF.Hardware.Netduino;

namespace RgbPwmLed
{
    public class Program
    {
        public static void Main()
        {
            // create a new pwm controlled RGB LED on pins Red = 11,
            // Green = 10 and Blue = 9.
            var rgbPwmLed = new Netduino.Foundation.LEDs.RgbPwmLed(
              N.PWMChannels.PWM_PIN_D11, // RED
              N.PWMChannels.PWM_PIN_D10, // GREEN
              N.PWMChannels.PWM_PIN_D9,  // BLUE
              2.1f,
              3.0f,
              3.0f, 
              false);

            // run forever
            while (true)
            {
                rgbPwmLed.SetColor(Color.FromHex("#FF0000"));
                Debug.Print("=========== RED! ===========");
                Thread.Sleep(1000);

                rgbPwmLed.SetColor(Color.FromHex("#00FF00"));
                Debug.Print("=========== GREEN! ===========");
                Thread.Sleep(1000);

                rgbPwmLed.SetColor(Color.FromHex("#0000FF"));
                Debug.Print("=========== BLUE! ===========");
                Thread.Sleep(1000);
            }
        }
    }
}

Credits

Jorge Ramírez

Jorge Ramírez

16 projects • 20 followers
Software developer getting into Hardware in the .Net world! Music lover, guitar enthusiast, intermediate hiker, and bike commuter!
bryan costanich

bryan costanich

16 projects • 18 followers
Adrian Stevens

Adrian Stevens

16 projects • 13 followers

Comments