adafruit / adafruit/Adafruit_CircuitPython_NeoPixel

Code breaks when using only 2 leds

Open
#142 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
329
Forks
96
PR merge metrics
No merged PRs in 30d

Description

Hi, idk if this is happening because its a niche use-case, but I have a project for my job where I'm trying to initialize a "strip" of only two ws2812b LEDs and make them blink red and green. I've been following this guide (which uses this library) to do so: https://core-electronics.com.au/guides/raspberry-pi/fully-addressable-rgb-raspberry-pi/

The problem I'm having is that whenever I try to control the LEDs, they behave unpredictably, and im unable to get the colors I want to appear. Instead when I run the script, the LEDs stay dark for between 30-45 seconds (the timing is different each run, I've timed it), then they each appear as a random color. On one execution, they may appear orange/blue, another magenta/yellow, there was even one time only one LED came on at a time, so I have no clue what's happening here.

I verified that it wasn't my code that was the issue by essentially copy/pasting the code in the guide, but accounting for only 2 leds, but got the random behavior described above. I was able to get that same code to work once before on an older system, but after updating python on my pi (from python2, it was an older version of raspbian and presumably the library too) everything broke and ive been unable to revert back. Now that older system can't even see the neopixel module.

Since then, I've flashed another sd card with a fresh install of the latest version of raspbian (twice) and followed the linked guide to the letter, but now i'm back to getting that random behavior again. I've also tried installing the same packages on the same version of raspbian that I got it to work with before, but pip keeps throwing syntax errors when i try to install the package, when it just did on the newer OS.

Now I'm starting to rub against my deadline for this project and I've exhausted the solutions I can think of on my own. Can I please get some assistance with this issue?

This is the code im using:
```python
import neopixel
from time import sleep
import board

strip = neopixel.NeoPixel(board.D18, 2)

while True:
strip[0] = (0, 204, 0)
strip[1] = (204, 0, 0)

sleep(.1)

strip[0] = (0, 0, 0)
strip[1] = (0, 0, 0)

sleep(1)

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided Python snippet and comparing it with the linked Raspberry Pi guide, focusing on the NeoPixel initialization with two LEDs. Done means determining whether two-LED strips are supported and reproducing or resolving the delayed random-color behavior on the stated Raspberry Pi and Raspbian setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.