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.

EasyFull instructions provided1 hour347

Things used in this project

Story

Read more

Schematics

Common Cathode RGB LED circuit

Rgb cathode elrowecrs5

Common Anode RGB LED Circuit

Rgb anode dhwyyfhnla

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

6 projects • 10 followers
Contact
bryan costanich

bryan costanich

6 projects • 8 followers
Contact
Adrian Stevens

Adrian Stevens

6 projects • 6 followers
Contact

Comments