MadeInTheUSB
Published © MIT

USB MultiColor Saint Valentin Love Cup Controlled with C#

USB MultiColor Saint Valentin Love Cup controlled with C#

IntermediateProtip1,079
USB MultiColor Saint Valentin Love Cup Controlled with C#

Things used in this project

Hardware components

SparkFun microB USB Breakout
SparkFun microB USB Breakout
×1

Story

Read more

Code

Untitled file

C#
public static void RainbowDemo2(APA102LEDStrip ledStrip, int jStep)
{
    Console.Clear();
    ConsoleEx.TitleBar(0, "Rainbow Demo");
    ConsoleEx.WriteMenu(-1, 2, "Q)uit");
    ConsoleEx.WriteMenu(-1, 3, "");

    int brigthness = 6;
    int wait        = GetWaitTimeUnit(ledStrip)/2;
    var quit        = false;
    ledStrip.AllOff();

    while (!quit) 
    {                
        for(var j=0; j < 256; j += jStep) 
        {
            ConsoleEx.Gotoxy(0, 4);
            ledStrip.Reset();

            for (var i = 0; i < ledStrip.MaxLed; i++)
            {
                ledStrip.AddRGBSequence(false, brigthness, RGBHelper.Wheel((i * 256 / ledStrip.MaxLed) + j));
            }
            for (var i = 0; i < ledStrip.MaxLed; i++)
            {
                var wheelIndex = (i * 256 / ledStrip.MaxLed) + j;
                var bkColor = ledStrip.LedColors[i];
                Console.WriteLine(String.Format("Color:{0}, Wheel:{1}, rgb:{2}", 
                    bkColor.Name,  wheelIndex.ToString("000"), APA102LEDStrip.ToDecValue(bkColor)));
            }
            ledStrip.Show().Wait(wait);    
            if(Console.KeyAvailable) 
            {
                var k = Console.ReadKey(true).Key;
                if (k == ConsoleKey.Q) 
                { 
                    quit = true;
                    break;
                }
            }
        }
    }
    ledStrip.AllOff();
}

Credits

MadeInTheUSB
3 projects • 0 followers
MadeInTheUSB, creator of the Nusbio USB Device for .NET.

Comments