# BlinkStick Square - SetColor doesn't work for index 0

**URL:** <https://forums.blinkstick.com/t/blinkstick-square-setcolor-doesnt-work-for-index-0/1423>\
**Category:** Support\
**Created:** [January 21, 2021, 12:59am UTC](https://forums.blinkstick.com/t/blinkstick-square-setcolor-doesnt-work-for-index-0/1423 "2021-01-21T00:59:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://forums.blinkstick.com/u/Daniel)\
**Post date:** [January 21, 2021, 12:59am UTC](https://forums.blinkstick.com/t/blinkstick-square-setcolor-doesnt-work-for-index-0/1423/1 "2021-01-21T00:59:11Z")

</div>

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;
> }
> 
> ```
