I've been successful getting one LED to fade on and off but i'm having trouble with two.
The problem with my code is the first LED fades on and off. STOPS
Then the second LED fades on and off on a loop while the first LED stays constantly on
without fading. (If that makes sense)
What i'm trying to accomplish Is having the two LED's fading alternately but so there's
a continuous flow between them. As if the lights fading from one and into the other.
Also I will most likely have to buy a microphone to plus into the board for this but is
there a way to activate this program when it detects sound?
Any questions just ask
Regards, Ryan
//Libraries that our program uses using System; //use base classes using System.Threading; //use threading classes using Microsoft.SPOT; //use smart personal objects technology classes using Microsoft.SPOT.Hardware; //use hardware related SPOT classes using SecretLabs.NETMF.Hardware; //use Secret Labs hardware framework using SecretLabs.NETMF.Hardware.Netduino; //use the Netduino specific classes namespace NCIR02 /// Define the namespace we are in /// { public class Program /// Define any variables used in the program and subrout //ines after Main()/// { static PWM[] leds = new PWM[8]; //An array to hold the 8 pins the LE //Ds are connected to public static void Main() /// The Main loop (run at power up) /// { /// Setup Portion of Program, runs once at startup /// //Set each LED pin to be an output leds[0] = new PWM(Pins.GPIO_PIN_D9); leds[1] = new PWM(Pins.GPIO_PIN_D10); while (true) /// Do Forever /// { //oneAfterAnotherNoLoop(); //Turn on each LED one by one then turn them off oneAfterAnotherLoop(); //This does the same as oneAfterAnotherNoLoop() but with much less typing //oneOnAtATime(); //Turns each LED on one after the other //inAndOut(); //Displays a Nightrider effect } /// Close Forever Loop /// } /// Close the Main() Loop /// /// <summary> /// Will light one LED then delay for delayTime then light /// the next LED until all LEDs are on it will then turn them off one after another. /// This does not use a loop and is similar to the method used in NCIR01 /// </summary> static void oneAfterAnotherLoop() { int delaytime = 30; for (uint i = 0; i < 100; i++) //Loop to fade from off to full on { leds[0].SetDutyCycle(i); //Sets the duty cycle to the variable i (0-100) Thread.Sleep(delaytime); //wait for 15 milliseconds } for (uint i = 100; i > 0; i--) //Loop to fade from full on to off { leds[0].SetDutyCycle(i); //Sets the duty cycle to the variable i (100-0) Thread.Sleep(delaytime); //wait for 15 milliseconds for (uint f = 0; f < 100; f++) { leds[1].SetDutyCycle(f); Thread.Sleep(delaytime); } for (uint f = 100; f > 0; f--) { leds[1].SetDutyCycle(f); Thread.Sleep(delaytime); } } } /// Close Forever Loop /// } /// Close the Main() Loop /// } /// Close the Program Loop /// /// Close the Namespace Loop ///