Basic Python help

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?


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.

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.


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


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


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

But that’d be a lot slower.