Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi Zero W and through-hole LED #303

Closed
jaguillette opened this issue Jul 25, 2018 · 2 comments
Closed

Raspberry Pi Zero W and through-hole LED #303

jaguillette opened this issue Jul 25, 2018 · 2 comments

Comments

@jaguillette
Copy link

jaguillette commented Jul 25, 2018

I'm pretty new to Raspberry Pi, but I've been trying out these through-hole LED neopixels, and I've been getting some strange results. I'm working on a breadboard, and have my power rail hooked up to pin 2 (5V output), ground rail hooked up to pin 6 (ground), and the input on the first LED hooked up to pin 12 (GPIO18). (I'm using this diagram as a reference)

I've written a test script to see if I can get the lights to do what I expect, and haven't had any luck with either SK6812_STRIP or SK6812W_STRIP as the LED_STRIP. Here it is, with the behavior I expect in the print statements, and the behavior that I'm getting in the comments:

import time
from neopixel import *

# LED strip configuration:
LED_COUNT      = 5       # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53+
LED_STRIP      = ws.SK6812_STRIP

strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP)

rLED = Color(255,0,0)
bLED = Color(0,255,0)
gLED = Color(0,0,255)

def allOne(strip, color):
    for i in range(strip.numPixels()):
        strip.setPixelColor(i,color)
    strip.show()
    return 0

strip.begin()

strip.setPixelColor(0,rLED)
strip.show()
print("RED LED 0")
# SK6812_STRIP, SK6812W_STRIP: LED 1 is red, LED 0 is off
time.sleep(5)

strip.setPixelColor(0,bLED)
strip.show()
print("BLUE LED 0")
# SK6812_STRIP: LED 0 is blue
time.sleep(5)

strip.setPixelColor(0,gLED)
strip.show()
print("GREEN LED 0")
# SK6812_STRIP: LED 1 is green, LED 0 is off
time.sleep(5)

allOne(strip,rLED)
print("RED LIGHTS")
# SK6812_STRIP: all red, but LED 0 off
# SK6812W_STRIP: 0:off 1:red 2:green 3:blue 4:off
time.sleep(5)

allOne(strip,bLED)
print("BLUE LIGHTS")
# SK6812_STRIP: all blue
# SK6812W_STRIP: 0:blue 1:off 2:red 3:green 4:blue
time.sleep(5)

allOne(strip,gLED)
print("GREEN LIGHTS")
# SK6812_STRIP: all green, but LED 0 off
# SK6812W_STRIP: 0:off 1:green 2:blue 3:off 4:red

(edited this code when I realized I wasn't including the LED_STRIP parameter when creating my strip object, oops)

I seem to be experiencing some slightly different behavior from what's mentioned in issue #198, but that was the most similar issue that I could find. I have a blacklist file at /etc/modprobe.d/snd-blacklist.conf that just contains blacklist snd_bcm2835, and I also have both of the following lines in my /boot/config.txt file:

hdmi_force_hotplug=1
hdmi_force_edid_audio=1

I'd appreciate any suggestions! I've been trying different LED_STRIP settings to no avail, but if I find one that works I'll post back here.

@penfold42
Copy link
Contributor

You need a level shifter.

Got a spare diode ? Put it in series with 5v power to the leds

@jaguillette
Copy link
Author

Ah, that seems to have done the trick! I didn't have a pile of diodes yet, so I got one. I'm getting a bit of flickering on the rainbow effects in strandtest.py, but I think I'll be able to tweak that somehow. I also got a level shifting chip from adafruit that I haven't tried yet, but which should also help. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants