WS2812B-16 Fast power-up, Fixed color

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Hi guys, I have an LED matrix of 4x4 WS2812B LEDs, and I'm looking to set it up to all be one color that activates when the top of a box is opened, closing a microswitch to power it up. Trouble is, I'm VERY new to this type of LED and the signals needed to set the colors. I've never used an Arduino or Raspberry Pi, but I'm eager to learn! I have some background knowledge of electronics, and if this were a standard LED, it would be no problem. I'd like to keep the controller board as small as possible, and I'd like to be able to set the color and have it stick until I change it, so that when it powers off, it will retain the color setting when it powers up again. Can anyone recommend a good, small controller I could use? This matrix has GND, IN, VCC, and OUT solder pads. Thanks for all your help!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B-16 Fast power-up, Fixed color

Post by adafruit_support_bill »

I'd start by having a read through the guide: https://learn.adafruit.com/adafruit-neopixel-uberguide

This type of pixel requires a microcontroller to drive them. Most any microcontroller will do. This is the tiniest one we make & will easily handle your matrix: https://learn.adafruit.com/adafruit-tri ... on-arduino

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thanks so much! I'll give it a good read! I appreciate the info!

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thanks! This helped a lot! I'm waiting for the boards to arrive now (had to go to digikey though, as they were out of stock here). I'm going to be running this from a battery pack, and I will be connecting two outside microswitches connected in series (they will either trigger the board or turn the power on when a person opens the box AND the weighted item is IN the box) and I'm wondering if you might have any recommendations for a battery configuration and small enclosure (they will be underneath a large foam insert inside the larger box)? I will be attaching the light array to a clear plexiglass plate to act as a pressure plate and flip one of the microswitches. Thanks again! I expect there will need to be 3 connections: the light array, the switches, and the power pack. We'll likely be using either AA or AAA rechargeable batteries. If there's a better power configuration for this, I'm open to it!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B-16 Fast power-up, Fixed color

Post by adafruit_support_bill »

3 AA or AAA rechargeable cells will supply about 3.6v which should work for both the Trinket M0 and the WS2812 pixels (the pixels are officially rated for 5v, but we regularly run them with 3.7v LiPo cells with no issues).

A 3.7v LiPo would be a good alternative to the AA/AAA cells. The LiPo has a higher power density, so it will give you a higher capacity and longer run-time from the same or smaller volume. LiPos come in a variety of capacities & shapes. One of the flat-pack style might be a good match for your enclosure: https://www.adafruit.com/category/574

For comparison, a 3x battery pack made from rechargeable AA cells will give you around 2000 mAh. With AAA cells, about 800mAh.

A typical 2500mAh LiPo will have about half the volume of a 3xAA pack.

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thanks! I'll check out that Lipo... so I guess I just have a few more questions... how would I charge the LiPo without overcharging it? Is there a charger you guys offer? Also, now that I received the Trinket M0s, I see there's a 3v solder point as well as a Bat one, and some of these connections I'm not sure what they do. Is there any place I can find a board pinout diagram and some example circuits? Also, if I plug this into my USB port on my PC, would that power it enough for me to program it, or does it also need external power? I'm having a little trouble finding these things on the website, though I'm probably just not looking in the right place. Thanks again! I wish I could find a little pdf or booklet that teaches all about this. I don't know either of the languages it uses yet, either, so I'll need some syntax and function info for those, too. I'm very excited to start using these! Thanks again for all your help!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B-16 Fast power-up, Fixed color

Post by adafruit_support_bill »

Is there a charger you guys offer?
We have a variety of chargers here: https://www.adafruit.com/category/575
Is there any place I can find a board pinout diagram and some example circuits?
Pinouts, programming information and other details are covered in the documentation for the board: https://learn.adafruit.com/adafruit-tri ... o/overview

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thanks again! I'm so glad I found you guys, and I really appreciate all your help! Now I'm off to download this info and get started! You guys rock!

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Hi again, all. I have the Trinket M0 and the WS2812B-16 (a 4x4 array of 16 WS2812B LEDs, which I understand to be DotStars?). I am trying to illuminate the entire panel with blue, then gradually shift it to green, then back. So far, I've only managed to get a few of the LEDs to light up, and the results are anything but predictable. I'm trying to use the DotStar example for CircuitPython 8.1, and I'm connecting the VCC line of the array to pin 0, and the IN of the array to pin 2 on the Trinket M0, and of course, ground to ground. I'm going by the pin assignments in the chart for the Trinket M0. I'd be glad to post the code if needed, but it's here on the website. Could someone please educate me on where I'm going wrong? I'm new to PWM signals and digital circuits/microcontrollers (I'm sure it shows lol) but I'm eager to learn and if I could get an example that works for this LED array, I am confident I could learn from it and tinker it into the code I need. Thanks so much!

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

20230621_161400.jpg
20230621_161400.jpg (432.22 KiB) Viewed 73 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B-16 Fast power-up, Fixed color

Post by adafruit_support_bill »

(a 4x4 array of 16 WS2812B LEDs, which I understand to be DotStars?
WS2812B LEDs are Neopixels. Dotstars use the APA102 or SK9822 LED. The control protocol for Dotstars and Neopixels is completely different. So you will need to use the Neopixel library.

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thank you for that clarification! I'm using this code, modified from the examples:
(I do believe you, but the odd thing is that it is detecting DotStar)

Code: Select all

# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""CircuitPython Essentials Internal RGB LED red, green, blue example"""
import time
import board
from rainbowio import colorwheel

num_pixels = 1
temp = (0, 0, 0)

if hasattr(board, "APA102_SCK"):
    import adafruit_dotstar
    print("DotStar Detected")
    led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
    pixels = adafruit_dotstar.DotStar(board.A1, board.A2, 16, brightness=0.1, auto_write=False)
else:
    import neopixel
    led = neopixel.NeoPixel(board.NEOPIXEL, 1)
    print("NeoPixel Detected")

def color_fill(color, wait):
    pixels.fill(color)
    pixels.show()
    time.sleep(wait)

def rainbow_cycle(wait):
    for j in range(255):
        for i in range(num_pixels):
            rc_index = (i * 256 // num_pixels) + j
            temp = colorwheel(rc_index & 255)
            led[0] = temp
            # print(temp)
            pixels.fill(temp)
        pixels.show()
        time.sleep(wait)

RED = (255, 0, 0)
YELLOW = (255, 150, 0)
ORANGE = (255, 40, 0)
GREEN = (0, 255, 0)
TEAL = (0, 255, 120)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
MAGENTA = (255, 0, 20)
WHITE = (255, 255, 255)

led.brightness = 0.05

while True:
    # Increase this number to slow down the rainbow animation.
    rainbow_cycle(.01)
Last edited by adafruit_support_bill on Wed Jun 21, 2023 6:13 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code to the forums

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

I can see a few issues with my code. It detects the on-board dotstar and never loads the neopixel library, for one. But I am having trouble finding example code for neopixel arrays.

User avatar
jamestbfraser
 
Posts: 14
Joined: Thu Jun 08, 2023 4:28 pm

Re: WS2812B-16 Fast power-up, Fixed color

Post by jamestbfraser »

Thanks again! I got it working! I found an example and also another info page on your site. Once I plugged the vcc to the 3.3v out on the Trinket and adjusted the example code to use the A1 pin, it sprang to life! I'm curious, however, because the same function sets both the neopixel array and the on-board dotstar, yet the dotstar is color-shifting at rocket speed, while the neopixels are slowly shifting like I expected.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: WS2812B-16 Fast power-up, Fixed color

Post by adafruit_support_bill »

Congratulations on getting it working!
the dotstar is color-shifting at rocket speed, while the neopixels are slowly shifting like I expected.
Not sure what your function looks like. But there are a couple of reasons why the Dotstar may be faster:

1) The Dotstar protocol is clocked, so it is capable of updating much faster than the Neopixel protocol which has a fixed data rate.

2) If your function involves iterating through the pixels, it takes more time to iterate through a string of 16 than it does to update a single pixel.

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

Return to “General Project help”