Created
November 16, 2014 21:22
-
-
Save arvydas/7413d77fe40278be0910 to your computer and use it in GitHub Desktop.
Test BlinkStick Pro with NeoPixels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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