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 hour1,350

Things used in this project

Hardware components

Netduino
Wilderness Labs Netduino
×1
SparkFun LED - RGB Clear Common Anode
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Visual Studio 2015
Microsoft Visual Studio 2015

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

74 projects • 73 followers
Developer advocate for Wilderness Labs.
bryan costanich

bryan costanich

70 projects • 53 followers
Adrian Stevens

Adrian Stevens

70 projects • 43 followers

Comments