unkwntech

8 RGBLED FUN!

Apr 7th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using System.Threading;
  2. using NetduinoGo;
  3.  
  4. namespace NetduinoGo_Test
  5. {
  6.     public class Program
  7.     {
  8.         private static readonly byte[][] Colours = new byte[8][];
  9.         public static void Main()
  10.         {
  11.             Colours[0] = new byte[] { 255, 0, 0 }; //Red
  12.             Colours[1] = new byte[] { 255, 29, 206}; //Pink
  13.             Colours[2] = new byte[] { 244, 128, 0 }; //Orange
  14.             Colours[3] = new byte[] { 255, 255, 0 }; //Yellow
  15.             Colours[4] = new byte[] { 29, 249, 20 }; //Lime
  16.             Colours[5] = new byte[] { 0, 255, 0 }; //Green
  17.             Colours[6] = new byte[] { 0, 0, 255 }; //Blue
  18.             Colours[7] = new byte[] { 255, 0, 255 }; //Purple
  19.  
  20.             RgbLed[] leds = new RgbLed[8];
  21.             //leds[0] = new RgbLed();
  22.             for (int i = 0; i < leds.Length; i++)
  23.                 leds[i] = new RgbLed();
  24.  
  25.             int current = 0, pos = 0;
  26.             while (true)
  27.             {
  28.                 current = pos;
  29.                 for(int i = 0; i<leds.Length; i++)
  30.                 {
  31.                     if (current > 7)
  32.                         current = 0;
  33.  
  34.                     leds[i].SetColor(Colours[current][0], Colours[current][1], Colours[current][2]);
  35.                     current++;
  36.                 }
  37.                 if (pos == 7)
  38.                     pos = 0;
  39.                 else
  40.                     pos++;
  41.  
  42.                 Thread.Sleep(125);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment