# Error when using set\_led\_data(0, data) in Python

**URL:** <https://forums.blinkstick.com/t/error-when-using-set-led-data-0-data-in-python/1018>\
**Category:** Support\
**Created:** [August 1, 2018, 10:31am UTC](https://forums.blinkstick.com/t/error-when-using-set-led-data-0-data-in-python/1018 "2018-08-01T10:31:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![icecherryhd](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/i/71e660/32.png) [@icecherryhd](https://forums.blinkstick.com/u/icecherryhd)\
**Post date:** [August 1, 2018, 10:31am UTC](https://forums.blinkstick.com/t/error-when-using-set-led-data-0-data-in-python/1018/1 "2018-08-01T10:31:14Z")

</div>

This is the example code im trying to use:

```
from blinkstick import blinkstick
from time import sleep, time
from colorsys import hsv_to_rgb

speed = 1
fps = 50.0
cut = 2
brightness = 1.0

stk = blinkstick.find_first()
cnt = 2

while True:
    data = []
    for i in range(1,cnt+1):
        (r, g, b) = hsv_to_rgb(i/float(cnt*(1.0/cut))+time()*speed, 1, brightness)
        data = data + [int(g*255), int(r*255), int(b*255)]
        #print(int(r*255), int(g*255), int(b*255), i/32.0,)
    stk.set_led_data(0, data)
    sleep(1/fps)

```

This is the error im getting:

```
Traceback (most recent call last):
  File "C:/Users/Daniel/PycharmProjects/Blinkstick/toys-master/rotatingrainbow.py", line 26, in <module>
    stk.set_led_data(0, data)

  File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 458, 
    in set_led_data
   self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, bytes(bytearray(report)))

 File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 226, in 
  _usb_ctrl_transfer
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])

  File "C:\Users\Daniel\PycharmProjects\Blinkstick\venv\lib\site-packages\blinkstick\blinkstick.py", line 226, 
in <listcomp>
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])

TypeError: ord() expected string of length 1, but int found

```

Im using a BlinkstickFlex Chip with 2 Leds attached to it. I used this code with the same board before once and it worked perfectly. I dont know why it doesnt now…

Im also using Pyhton 3.5

I searched around the Forums but couldn’t find any help to my problem.

---

<div class="post-metadata">

**Author:** ![p0ke](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/p0ke/32/14_2.png) [@p0ke](https://forums.blinkstick.com/u/p0ke)\
**Post date:** [August 1, 2018, 11:40am UTC](https://forums.blinkstick.com/t/error-when-using-set-led-data-0-data-in-python/1018/2 "2018-08-01T11:40:26Z")

</div>

Please take a look at the issues regarding this at github:

> <https://github.com/arvydas/blinkstick-python/issues/34>

---

<div class="post-metadata">

**Author:** ![icecherryhd](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/i/71e660/32.png) [@icecherryhd](https://forums.blinkstick.com/u/icecherryhd)\
**Post date:** [August 1, 2018, 2:29pm UTC](https://forums.blinkstick.com/t/error-when-using-set-led-data-0-data-in-python/1018/3 "2018-08-01T14:29:50Z")

</div>

Thank you. It’s working again 🙂

(Also thanks for the fast reply)
