Display random(??) RGB led color pattern. Change the sleep time to make it less annoying. Tried to keep intensity down - next time, larger R!
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
namespace NetduinoPlusApplication1
{
public class Program
{
public static void Main()
{
PWM red_led = new PWM(PWMChannels.PWM_PIN_D9, 100, 50, false);
PWM green_led = new PWM(PWMChannels.PWM_PIN_D10, 100, 50, false);
PWM blue_led = new PWM(PWMChannels.PWM_PIN_D6, 100, 50, false);
double red_duty_cycle = 5;
double green_duty_cycle = 11;
double blue_duty_cycle = 19;
int color_count = 1;
while (true)
{
++color_count;
red_duty_cycle += color_count;
if (red_duty_cycle > 50) { red_duty_cycle = 5; }
red_led.DutyCycle += blue_duty_cycle / 100;
green_duty_cycle += color_count;
if (green_duty_cycle > 50) { green_duty_cycle = 1; }
green_led.DutyCycle = green_duty_cycle / 100;
blue_duty_cycle += color_count;
if (blue_duty_cycle > 50) { blue_duty_cycle = 2; }
blue_led.DutyCycle = blue_duty_cycle / 100;
Debug.Print("color_count = " + color_count.ToString());
Debug.Print("red = " + red_duty_cycle.ToString());
Debug.Print("green = " + green_duty_cycle.ToString());
Debug.Print("blue = " + blue_duty_cycle.ToString());
Debug.Print(" ");
if (color_count > 20) { color_count = 1; }
Thread.Sleep(3000);
}
}
}
}