It is not working and I am stuck as to why.
Here is your original code which works on one wheel. I had to change the numpix to 16 of course but it works quite fine:
Code: Select all
# CircuitPython demo - NeoPixel
import board
import neopixel
import time
pixpin = board.D1
numpix = 10
strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.3, auto_write=False)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if (pos < 0) or (pos > 255):
return (0, 0, 0)
if (pos < 85):
return (int(pos * 3), int(255 - (pos*3)), 0)
elif (pos < 170):
pos -= 85
return (int(255 - pos*3), 0, int(pos*3))
else:
pos -= 170
return (0, int(pos*3), int(255 - pos*3))
def rainbow_cycle(wait):
for j in range(255):
for i in range(len(strip)):
idx = int ((i * 256 / len(strip)) + j)
strip[i] = wheel(idx & 255)
strip.write()
time.sleep(wait)
while True:
strip.fill((255, 0, 0))
strip.write()
time.sleep(1)
strip.fill((0, 255, 0))
strip.write()
time.sleep(1)
strip.fill((0, 0, 255))
strip.write()
time.sleep(1)
rainbow_cycle(0.001) # rainbowcycle with 1ms delay per step
OK so here is what I did.
First I commented out all of the the 'While True' blinking part since I just wanted to work on the rainbow cycle. Then I changed pixpin to pixpinLeft and Right and the right board to board.D0
I changed strip to stripLeft and Right and idx to idxL and R. Lastly (and I suspect that this is the problem) I changed 'write' to 'show' as it is on the goggles code and made it into showLeft and showRight. I have also tried it as writeLeft and writeRight and just write but no luck.
What am I doing wrong?
# CircuitPython demo - NeoPixel
import board
import neopixel
import time
pixpinLeft = board.D1
pixpinRight = board.D0
numpix = 16
stripLeft = neopixel.NeoPixel(pixpin, numpix, brightness=0.3, auto_write=False)
stripRight = neopixel.NeoPixel(pixpin, numpix, brightness=0.3, auto_write=False)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if (pos < 0) or (pos > 256):
return (0, 0, 0)
if (pos < 85):
return (int(pos * 3), int(255 - (pos*3)), 0)
elif (pos < 170):
pos -= 85
return (int(255 - pos*3), 0, int(pos*3))
else:
pos -= 170
return (0, int(pos*3), int(255 - pos*3))
def rainbow_cycle(wait):
for j in range(255):
for i in range(len(stripLeft)):
idxL = int ((i * 256 / len(stripLeft)) + j)
stripLeft[i] = wheel(idxL & 255)
idxR = int ((i * 256 / len(stripRight)) + j)
stripRight[i] = wheel(idxR & 255)
stripLeft.show()
stripRight.show()
time.sleep(wait)
while True:
# strip.fill((255, 0, 0))
# strip.write()
# time.sleep(1)
# strip.fill((0, 255, 0))
# strip.write()
# time.sleep(1)
# strip.fill((0, 0, 255))
# strip.write()
# time.sleep(1)
rainbow_cycle(0.001) # rainbowcycle with 1ms delay per step