PyPortal and NeoPixels

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

PyPortal and NeoPixels

Post by oldblackcrow »

Hello all! I purchased NeoPixel LED Strip with 3-pin JST PH Connector - 60 LED/meter / 0.5 Meter and connected them to my PyPortal Pynt.
I only need 3 neopixels from the strip, so I cut after the 3rd neopixel.

After I ran the various version of the below code, I connected my power supply to only the hot and ground of the neopixels and the first neopixel lit up white.

I know the 3pin JST ports are marked incorrectly and have tried changing the following:
1. added PyPortal library references
2. changed the pixel pin to "pixel_pin = board.D3" and I tried "pixel_pin = board.D4"
Also tried "d3" and d4"
3. Then I tried commenting out the "pixels.fill((0, 255, 0))" and uncommenting the "pixels.fill((0, 255, 0, 0))" on all three sections.
4. Changed "RDER= RGB" to "RDER = neopixel.RGBW" and "RDER = neopixel.GRBW"

The lights do not come on at all.

I am at a loss. Thank you for your help!

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import neopixel
from adafruit_pyportal import PyPortal

# On CircuitPlayground Express, and boards with built in status NeoPixel -> board.NEOPIXEL
# Otherwise choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D1
pixel_pin = board.NEOPIXEL

# On a Raspberry pi, use this instead, not all pins are supported
pixel_pin = board.D3

# The number of NeoPixels
num_pixels = 3

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
ORDER = neopixel.GRBW

pixels = neopixel.NeoPixel(
    pixel_pin, num_pixels, brightness=0.2, auto_write=False, pixel_order=ORDER
)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        r = g = b = 0
    elif pos < 85:
        r = int(pos * 3)
        g = int(255 - pos * 3)
        b = 0
    elif pos < 170:
        pos -= 85
        r = int(255 - pos * 3)
        g = 0
        b = int(pos * 3)
    else:
        pos -= 170
        r = 0
        g = int(pos * 3)
        b = int(255 - pos * 3)
    return (r, g, b) if ORDER in (neopixel.RGB, neopixel.GRB) else (r, g, b, 0)


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(num_pixels):
            pixel_index = (i * 256 // num_pixels) + j
            pixels[i] = wheel(pixel_index & 255)
        pixels.show()
        time.sleep(wait)


while True:
    # Comment this line out if you have RGBW/GRBW NeoPixels
    #pixels.fill((255, 0, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    pixels.fill((255, 0, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    #pixels.fill((0, 255, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 255, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    #pixels.fill((0, 0, 255))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 0, 255, 0))
    pixels.show()
    time.sleep(1)

    rainbow_cycle(0.001)  # rainbow cycle with 1ms delay per step



User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: PyPortal and NeoPixels

Post by dastels »

Do you, in fact, have RGBW pixls (as opposed to RGB)?

Dave

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: PyPortal and NeoPixels

Post by oldblackcrow »

They are not, but I did try the RGB first and only attempted the WRGBs and the variants as a last ditch effort to get them to work.

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: PyPortal and NeoPixels

Post by dastels »

"W" order variants are just for NeoPixels with a white element. The datastream is different, with each picxel taking 32 bits rather than 24. Even so you should see *somewhing* regardless of the order setting. If the oder doesn't match the pixels you just won't get the right colors.

Can you post a clear photo of your wiring?

Dave

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: PyPortal and NeoPixels

Post by oldblackcrow »

Thanks Dave!

Here are the images.
PyPortal-with-RGB-strip002.jpg
PyPortal-with-RGB-strip002.jpg (462.13 KiB) Viewed 466 times
PyPortal-with-RGB-strip001.jpg
PyPortal-with-RGB-strip001.jpg (936.07 KiB) Viewed 466 times

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: PyPortal and NeoPixels

Post by oldblackcrow »

I'm wondering now... I changed the I2C voltage to 3v and noticed that the neopixels are 5v... don't know if that affects this or not. However, When I tested on my power supply, I had it set on 3v and one neopixel lit up, so you're right, I should get something.

Here is the current code I'm running just to make sure I'm not messing that up.

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import neopixel
from adafruit_pyportal import PyPortal

# On CircuitPlayground Express, and boards with built in status NeoPixel -> board.NEOPIXEL
# Otherwise choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D1
pixel_pin = board.NEOPIXEL

# On a Raspberry pi, use this instead, not all pins are supported
pixel_pin = board.D4

# The number of NeoPixels
num_pixels = 3

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
ORDER = neopixel.RGB

pixels = neopixel.NeoPixel(
    pixel_pin, num_pixels, brightness=1.0, auto_write=True, pixel_order=ORDER
)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        r = g = b = 0
    elif pos < 85:
        r = int(pos * 3)
        g = int(255 - pos * 3)
        b = 0
    elif pos < 170:
        pos -= 85
        r = int(255 - pos * 3)
        g = 0
        b = int(pos * 3)
    else:
        pos -= 170
        r = 0
        g = int(pos * 3)
        b = int(255 - pos * 3)
    return (r, g, b) if ORDER in (neopixel.RGB, neopixel.GRB) else (r, g, b, 0)


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(num_pixels):
            pixel_index = (i * 256 // num_pixels) + j
            pixels[i] = wheel(pixel_index & 255)
        pixels.show()
        time.sleep(wait)


while True:
    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((255, 0, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((255, 0, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 255, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((0, 255, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 0, 255))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((0, 0, 255, 0))
    pixels.show()
    time.sleep(1)

    rainbow_cycle(0.001)  # rainbow cycle with 1ms delay per step

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: PyPortal and NeoPixels

Post by oldblackcrow »

Any ideas here, or a workaround? Thanks!

User avatar
jerryn
 
Posts: 1868
Joined: Sat Sep 14, 2013 9:05 am

Re: PyPortal and NeoPixels

Post by jerryn »

I tried your code on my PyPortal -- and it works as expected.
A few observations --
in your code, you are using D4 for the neopixel, but you picture show it on D3.
In your code, you define pixel_pin twice -- the second one will be the one used, but just wanted t point it out.

in your photo, it does not look like either 3V or 5V is selected ( I don't see a solder bridge to either pad).
I have mine on 5V.

User avatar
oldblackcrow
 
Posts: 221
Joined: Tue Jun 20, 2017 5:54 pm

Re: PyPortal and NeoPixels

Post by oldblackcrow »

Thanks @jerryn!

I believe it was the 3v trace not being connected. I am using a second PyPortal Pynt with the trace soldered proper. Also, I did comment out that first pixel_pin.

However, just so you know, on the Pynt, the D3 and D4 are mismarked and so D3 is D4 and vice versa.

Thanks again!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”