# Basic Python help

**URL:** <https://forums.blinkstick.com/t/basic-python-help/1240>\
**Category:** Support\
**Created:** [August 13, 2019, 10:44pm UTC](https://forums.blinkstick.com/t/basic-python-help/1240 "2019-08-13T22:44:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuriytheking](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/y/73ab20/32.png) [@yuriytheking](https://forums.blinkstick.com/u/yuriytheking)\
**Post date:** [August 13, 2019, 10:44pm UTC](https://forums.blinkstick.com/t/basic-python-help/1240/1 "2019-08-13T22:44:10Z")

</div>

I have a Blinkstick Flex. I cut it down to 20 LEDs and installed it in my case. I would now like to run some basic commands with the Python API but I’m struggling to understand the help/examples. I am using Windows

What I want to do is:

1: check if a Blinkstick Flex is connected  
2: set each LED to a particular colour  
3: turn each LED off

Would someone be able to provide some basic python code to do the above?

Cheers

---

<div class="post-metadata">

**Author:** ![Diff](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/diff/32/553_2.png) [@Diff](https://forums.blinkstick.com/u/Diff)\
**Post date:** [October 7, 2019, 5:25am UTC](https://forums.blinkstick.com/t/basic-python-help/1240/2 "2019-10-07T05:25:38Z")

</div>

You’ll need to hit the docs, it’s been a while since I’ve messed with the blinkstick python API so you’ll need to correct my code. But this’ll give you the basic idea you need.

```auto
from blinkstick import blinkstick

stick = blinkstick.find_first()
count = blinkstick.get_led_count() # Note: Won't work for the Pro. Gotta maintain your own count there.

color = [0, 255, 0] # Red, in GRB format
data = color * count # Repeat color a bunch of times
stick.set_led_data(0, data) # Takes a list of GRB values for each LED and sends them all at once.

sleep(1)

color = [0, 0, 0] # And now black
data = color * count
stick.set_led_data(0, data)

```

Alternatively,

```auto
for i in range(20):
	stick.set_color(0, i, 255, 0, 0)

sleep(1)

for i in range(20):
	stick.set_color(0, i, 0, 0, 0)

```

But that’d be a lot slower.
