frame

Neopixels color change in a loop

riklaunim Member
edited August 30 in Libraries & Drivers
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)

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.


Comments

  • edited August 31
    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 :)
    Matteo Cipriani
    Zerynth Support Team
  • 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.

Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.