Most recent activity
-
@DrAzzy
That's sorted it !!Thanks for pointing me in the right direction.
-
@DrAzzy
I understand the parameters of setTimeout now, but if I place it outside of the loop surely I will only ever light the last two lights ?The timeout is needed to delay the step otherwise the pattern will complete in a flash, if you will forgive the pun !
Thanks
-
Hi,
I apologise in advance for this simple question.
I have just taken delivery of two strings of 50 WS2811 led's.
I can get all the sample code working and I have managed to extend the patterns of blinking but now I would like to try stepping patterns, ie light the first two led's and then step forwards lighting one led at a time and turning off the first led so that only two leds are lit at any one time.
Here is the code that I am playing with -
SPI2.setup({baud:3200000, mosi:B15}); var rgb = new Uint8ClampedArray(50*3); function step(pos) { if (pos > 0) { rgb[pos-1] = 0; } rgb[pos ] = 0; rgb[pos+1] = 0; rgb[pos+2] = 255; rgb[pos+3] = 0; rgb[pos+4] = 0; rgb[pos+5] = 255; } function doStep() { for (var i=0;i<rgb.length-3;i+=3) { step(i); setTimeout(SPI2.send4bit(rgb, 0b0001, 0b0011), 5000); } }
I know its ugly but I am just playing at the moment.
When I execute this the first two leds light and I get the following error -
Uncaught Error: Function or String not supplied: at line 4 col 56
Any pointers would be gratefully appreciated.
Okay maybe not the most exciting pattern but here is what I ended up with -