I am using the following code to try and set all 8 LEDs of the BlinkStick Square to a particular colour. The odd thing is that I can only get the first LED to light if use -1 as the start point for my index loop. There must be something wrong with my code, but I can’t figure it out.
Also, can someone explain what device.SetMode() I should be using for the BlinkStick Square and perhaps what that actually does. It seams to work with device.SetMode(2) right now unless that is causing the problem above?
private static BlinkStick[] controlBlinkSticks(String command) { //find all the blinkStick devices BlinkStick[] devices = BlinkStick.FindAll(); //Iterate through all of them foreach (BlinkStick device in devices) { //Open the device if (device.OpenDevice()) { device.SetMode(2); int leds = 8; if (command == "off") { for (int i = -1; i < leds; i++) { //turn off the device device.SetColor(0, (byte)i, "black"); } device.TurnOff(); } else if (command == "red" || command == "yellow" || command == "green" || command == "blue") { for (int i = -1; i < leds; i++) { //set the desired colour device.SetColor(0, (byte)i, command); } } } } return devices; }