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 hour267
Show Rainbow Colors with an RGB LED and Netduino

Things used in this project

Hardware components

Netduino3 WiFi
Netduino3 WiFi
×1
Netduino3 Ethernet
Netduino3 Ethernet
×1
Netduino3
Netduino3
×1
Netduino Plus 2
Netduino Plus 2
×1
Netduino 2
Netduino 2
×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

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

4 projects • 3 followers
Contact
bryan costanich

bryan costanich

4 projects • 3 followers
Contact
Adrian Stevens

Adrian Stevens

4 projects • 3 followers
Contact

Comments

Add projectSign up / Login