Skip to content

Instantly share code, notes, and snippets.

@arvydas
Created November 16, 2014 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvydas/7413d77fe40278be0910 to your computer and use it in GitHub Desktop.
Save arvydas/7413d77fe40278be0910 to your computer and use it in GitHub Desktop.
Test BlinkStick Pro with NeoPixels
using System;
using BlinkStickDotNet;
using System.Threading;
namespace IndexedColors
{
class MainClass
{
public static void Main (string[] args)
{
foreach (BlinkStick device in BlinkStick.FindAll())
{
if (device != null) {
if (device.OpenDevice ()) {
device.SetMode (2);
Thread.Sleep (1000);
int leds = 4;
runColor (device, "#ff0000", leds);
runColor (device, "#00ff00", leds);
runColor (device, "#0000ff", leds);
runColor (device, "#ffffff", leds);
} else {
Console.WriteLine ("Could not open the device");
}
} else {
Console.WriteLine ("BlinkStick not found");
}
}
}
private static void runColor(BlinkStick device, String color, int numberOfLeds = 8)
{
for (byte i = 0; i < numberOfLeds; i++) {
device.SetColor (0, i, color);
Thread.Sleep (100);
device.SetColor (0, i, "#000000");
Thread.Sleep (20);
Console.WriteLine (i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment