Neopixels color change in a loop


#1

I’m testing a 16-led ring of neopixels and in a while loop I’m switching colors:

import streams
from adafruit.neopixel import ledstrips as neo
streams.serial()

num_leds = 16
led_pin = D2

leds = neo.LedStrip(led_pin, num_leds)
leds.clear()

while True:
leds.clear()
leds.setall(100, 255, 100)
leds.on()
sleep(500)
leds.clear()
leds.setall(100, 100, 255)
leds.on()
sleep(500)

<br>It works but both on both Nucleo F401RE and Particle Photon every few loops the switching stops for a moment and some LEDs get a somewhat random color. What could be the cause of this? The LEDs seems to work fine with ESP32/Arduino neopixel code.<br><br><br>

#2

Hi riklaunim,

We’ve tested your code in both Particle Photon and Nucleo F401RE for a wile and this problem never appeared.
Which version of the Zerynth Studio are you using? After the bad behavior, the device resets itself or continues to run the script?

You can try to change the led_pin (we test with D2 and with D6).

Let me know :slight_smile:


#3

Version is 2.0.9. D2 is for Particle, while with Nucleo I used different one.

From what I see now it’s rather sort of electronics interference. When I moved the LED Ring with it cable away from power supply and the board it works correctly without odd colors.