Go Down

Topic: WS2812B randomly lighting up (Read 531 times) previous topic - next topic

Potheker

I'm using an Arduino in a larger project to simply write brightness values, received over Serial on pin 8, to a WS2812B with 53 LEDs. Everything works fine while powering everything over Arduinos USB-Port.

But as I need a more powerful power supply, I got myself one of those usual 5V 10A power supplys, cut the end of it and connected the 5v and GND wire through one of those connectors, which come with the WS2812B, to Arduino VIN/GND. When I do this (without changing the code obviously), from time to time some LEDs are lighting up randomly and also sometimes LEDs are lighting up in Green or Pink (no other colors, just those two), although my code doesn't have the possibility of sending any other color than white.

This doesn't happen when using USB Power. Also when the data received consists of only zeros (so nothing should light up) it also happens, but only with single LEDs lighting up rarely. With real data it happens way more often and with multiple LEDs in a row.

My Code:
Code: [Select]
#include "Adafruit_NeoPixel.h"
#include "SoftwareSerial.h"

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(53,6, NEO_GRB + NEO_KHZ800);
int currPixel = 52;
SoftwareSerial serial(8,99); //RX,TX

void setup() {
  serial.begin(38400);
  pixels.begin();
  pixels.show();
}

void loop() {
  if(serial.available())
  {
    byte in = serial.read();
    if(in == 255)
    {
      pixels.show();
      currPixel = 52;
    }
    else
    {
      pixels.setPixelColor(currPixel--,65793*in); //65793*x = White with x as brightness value (yes I already tested it using pixels.Color(in,in,in) instead, which effectively does the same thing)
    }
  }
}

Wawa

SoftwareSerial serial(8,99); //RX,TX
Why the 99?
What type of Arduino is this.

I got myself one of those usual 5V 10A power supplys, cut the end of it and connected the 5v and GND wire through one of those connectors, which come with the WS2812B, to Arduino VIN/GND.
V-in is the input of the onboard 5volt regulator, and needs 7-12volt for the regulator to make a stable 5volt for the Arduino (assuming Uno).
If you have a reliable regulated 5volt supply, then connect it to the 5volt pin.
Wise to disconnect that 5volt supply when you connect the Uno to USB to upload a new sketch.
Leo..

Grumpy_Mike

Software serial does not play well with the software needed to drive the WS2812 chip. This is because they both need to use interrupts and the LED driver disables those interrupts for lengthy periods when outputting fresh data. This causes some data to be missed or corrupted.
So once you have sent data that you know will result in an refresh of the strips, avoid sending more serial data for a time to allow the refresh to happen.

However you might have just neglected to have a large capacitor on the power input to the strips.

Paul__B

But as I need a more powerful power supply, I got myself one of those usual 5V 10A power supplies, cut the end of it and connected the 5v and GND wire through one of those connectors, which come with the WS2812B, to Arduino VIN/GND.
"Vin" and the "barrel jack" are the input to the on-board voltage regulator.  If you already have a regulated 5 V supply, you connect it to the 5 V pin.  Think - it is 5 V?  Makes sense doesn't it?  :smiley-roll:

It may be wise in case of fumble fingers, to put a 1 A fuse between the power supply and the 5 V line to the Arduino.  Not to protect the Arduino, but to protect your wiring.  Note that all supply and ground return lines must travel as a pair and the same for data connections, so if you have supply lines going from power supply to LED strip and supply lines going from power supply to Arduino, the data line for the LED strip should travel with those supply lines from Arduino to power supply junction, then back along the supply lines to the LED strip.  There should be no visible (closed) loops in the wiring.

Go Up