I've been turning over a few ideas regarding how to manage the RGB LED types we use. The code as supplied via this website, and seen inside the book on Netduinos most of us have read provided me with the clews to get these devices showed me how to step through color changes. The button one and even the blinking LED one, (not used in the code) provided other clews. However this is as far as I've gotten with convincing (or confusing) an RGB LED to change its colors via logic.
using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoMini; namespace Test74 { public class Program { public static void Main() { // write your code here PWM redLed = new PWM(Pins.GPIO_PIN_20); PWM greenLed = new PWM(Pins.GPIO_PIN_19); PWM blueLed = new PWM(Pins.GPIO_PIN_18); // change the color intensities redLed.SetDutyCycle(60); // 60% red intensity greenLed.SetDutyCycle(2); // 0% green intensity blueLed.SetDutyCycle(100); // 100% blue intensity // go to sleep Thread.Sleep(350); // write your code here OutputPort led = new OutputPort(Pins.GPIO_PIN_17, false); Thread.Sleep(350); InputPort button = new InputPort(Pins.GPIO_PIN_16, false, Port.ResistorMode.Disabled); bool buttonState = false; Thread.Sleep(350); while (true) { buttonState = button.Read(); led.Write(!buttonState); } // change the color intensities redLed.SetDutyCycle(0); // 60% red intensity greenLed.SetDutyCycle(75); // 0% green intensity blueLed.SetDutyCycle(0); // 100% blue intensity // go to sleep Thread.Sleep(350); } } }What I want to happen is that the block of code after the button event would accept two bit streams as inputs via specific GPIOs and then cause a color change to continue along further. Part of the problem is that I confess that I really do not understand C Sharp as well as I should. It happens.
Edited by Dr Who, 03 November 2012 - 03:59 AM.