I am trying to control a strip of WS2801 LEDs through an arduino uno running firmata from Python on my laptop.
I've written some basic code based on adafruit's library here (from line 187):
from pymata_aio.pymata3 import PyMata3
from pymata_aio.constants import Constants
import time
leds = [(255, 255, 0), (255, 255, 0), (0, 255, 255)]
uno = PyMata3()
uno.set_pin_mode(2, Constants.OUTPUT) # signal
uno.set_pin_mode(3, Constants.OUTPUT) # clock
def show(leds):
for pixel in leds:
for channel in pixel:
i = 0b1
for x in range(0,8):
if i & channel:
uno.digital_write(2, 1)
else:
uno.digital_write(2, 0)
uno.digital_write(3, 1)
uno.digital_write(3, 0)
i = i << 1
uno.digital_write(3, 0)
time.sleep(0.001)
When I run the code it seems to run ok, but only the first LED will light up. I think (too quick to be certain) that it flashes through all the colours - ie displaying each colour rather than passing them through.
I'm wondering if there is something wrong with the timing for the clock pin making it latch, but I'm grasping here.