Issue lighting up WS2811 strand with Nano 33

Hi there!

Been struggling on a my first Arduino project.

Basically I have a controller that is supposed to light up specific LEDs on a strip.

When I run the application, I am able to connect via blue tooth and trigger the commands to light up the LED (I was able to confirm this using the serial monitor in VS Code)

However, no matter what I do, I can't actually get the LEDs to light up.

Here is the setup of my board at the moment (excuse the exposed wiring! Been testing with multimeter when I took image)

The description of the LEDS I purchased were "25cm wire spacing 50pcs DC5V 12mm WS2811 led smart pixel node,with RGB wire(18AWG),IP68 rated;RGB addressable full color".

Here is a link to the board I purchased: https://www.digikey.ca/en/products/detail/arduino/ABX00030/10239969
Things I have done to troubleshoot so far

  1. Ensured LEDs were getting voltage by using using multimeter at the terminal end of the LED pigtail

  2. Added a resistor in the data line (it's not in the image)

  3. Tried changing data pin in source code to a different one (and moving the data wire accordingly)

  4. I have 4 strips of LEDs, I have cycled through a few strands to see if that has any impact

  5. Tried flashing with NeoPixel strandtest (Adafruit_NeoPixel/strandtest.ino at master · adafruit/Adafruit_NeoPixel · GitHub) and moving data to pin 6 to see if that works (to be honest, I have no idea if I did this one correctly)

Code:

#include <HardwareBLESerial.h>
#include <NeoPixelBus.h>
#include <config.h>

HardwareBLESerial &bleSerial = HardwareBLESerial::getInstance();

#ifdef GRB
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
#else
NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
#endif

RgbColor red(brightness, 0, 0);
RgbColor green(0, brightness, 0);
RgbColor blue(0, 0, brightness);
RgbColor violet(additionalledbrightness, 0, additionalledbrightness);
RgbColor black(0);

int state = 0; // Variable to store the current state of the problem string parser
String problemstring = ""; // Variable to store the current problem string
bool useadditionalled = false; // Variable to store the additional LED setting

void setup() {
  Serial.begin(9600);

  if (!bleSerial.beginAndSetupBLE("MoonBoard A")) { // Initialize BLE UART and check if it is successful
    // This should never happen as it means that the BLE setup failed and the program cannot run!
    while (true) {
      Serial.println("BLE setup failed!");
      delay(1000);
    }
  }

  strip.Begin(); // Initialize LED strip
  strip.Show(); // Good practice to call Show() in order to clear all LEDs

  // Test LEDs by cycling through the colors red, green, blue, violet and then turning the LEDs off again
  strip.SetPixelColor(0, red);
  for (int i = 0; i < PixelCount; i++) {
    strip.ShiftRight(1);
    strip.Show();
    delay(10);
  }
  strip.SetPixelColor(0, green);
  for (int i = 0; i < PixelCount; i++) {
    strip.ShiftRight(1);
    strip.Show();
    delay(10);
  }
  strip.SetPixelColor(0, blue);
  for (int i = 0; i < PixelCount; i++) {
    strip.ShiftRight(1);
    strip.Show();
    delay(10);
  }
  strip.SetPixelColor(0, violet);
  for (int i = 0; i < PixelCount; i++) {
    strip.ShiftRight(1);
    strip.Show();
    delay(10);
  }

  strip.ClearTo(black);
  strip.Show();

  // Wait for the MoonBoard App to connect
  while (!bleSerial);
}

void loop() {
  // Read messages from the BLE UART
  bleSerial.poll();
  
  // Check if message parts are available on the BLE UART
  while (bleSerial.available() > 0) {
    char c = bleSerial.read();

    // State 0: wait for configuration instructions (sent only if V2 option is enabled in app) or beginning of problem string
    if (state == 0) {
      if (c == '~') {
        state = 1; // Switch to state 1 (read configuration)
        continue;
      }
      if (c == 'l') {
        state = 2; // Switch to state 2 (read problem string)
        continue;
      }
    }

    // State 1: read configuration option (sent only if V2 option is enabled in app)
    if (state == 1) { 
      if (c == 'D') {
        useadditionalled = true;
        state = 2; // Switch to state 2 (read problem string)
        continue;
      }
      if (c == 'l') {
        state = 2; // Switch to state 2 (read problem string)
        continue;        
      }
    }

    // State 2: wait for the second part of the beginning of a new problem string (# after the lower-case L)
    if (state == 2) {
      if (c == '#') {
        state = 3; // Switch to state 3
        continue;
      }
    }

    // State 3: store hold descriptions in problem string
    if (state == 3) { 
      if (c == '#') { // problem string ends with #
        state = 4; // Switch to state 4 (start parsing and show LEDs)
        continue;
      }
      problemstring.concat(c); // add current character to problem string
    }
  }

  // State 4: complete problem string received, start parsing
  if (state == 4) {
    strip.ClearTo(black); // Turn off all LEDs in LED string
    Serial.println("\n---------");
    Serial.print("Problem string: ");
    Serial.println(problemstring);
    Serial.println("");

    String problemstringstore = problemstring; // store copy of problem string

    if (useadditionalled) { // only render additional LEDs in first loop
      Serial.println("Additional LEDs:");
      while(true){
        int pos = problemstring.indexOf(','); // Hold descriptions are separated by a comma (,)
        
        String hold;
        if (pos > 0) { // Still holds left in the problem string
          hold = problemstring.substring(0, pos); // Extract one hold description
        }
        else { // Last hold in the problem string
          hold = problemstring; 
        }

        char holdtype = hold.charAt(0); // Hold descriptions consist of a hold type (S, P, E) ...
        int holdnumber = hold.substring(1).toInt(); // ... and a hold number
        int lednumber = ledmapping[holdnumber];
        int additionallednumber = lednumber + additionalledmapping[holdnumber];
        if (additionalledmapping[holdnumber] != 0) {
          Serial.print(holdtype);
          Serial.print(holdnumber);
          Serial.print(" --> ");
          Serial.print(additionallednumber);
          if (holdtype == 'S') { // Start hold
            strip.SetPixelColor(additionallednumber, violet);
            Serial.println(" (violet)");
          }
          if (holdtype == 'P') { // Progress hold
            strip.SetPixelColor(additionallednumber, violet);
            Serial.println(" (violet)");
          }
          // Finish holds don't get an additional LED!
        }        

        if (pos == -1) { // Last hold has been processed!
          Serial.println("");
          break;
        }

        problemstring = problemstring.substring(pos+1, problemstring.length()); // Remove processed hold from string
      }

      problemstring = problemstringstore; // Restore problem string for rendering normal hold LEDs
    }

    Serial.println("Problem LEDs:");
    while(true){ // render all normal LEDs (possibly overriding additional LEDs)
      int pos = problemstring.indexOf(','); // Hold descriptions are separated by a comma (,)
      
      String hold;
      if (pos > 0) { // Still holds left in the problem string
        hold = problemstring.substring(0, pos); // Extract one hold description
      }
      else { // Last hold in the problem string
        hold = problemstring; 
      }

      char holdtype = hold.charAt(0); // Hold descriptions consist of a hold type (S, P, E) ...
      int holdnumber = hold.substring(1).toInt(); // ... and a hold number
      int lednumber = ledmapping[holdnumber];
      Serial.print(holdtype);
      Serial.print(holdnumber);
      Serial.print(" --> ");
      Serial.print(lednumber);
      if (holdtype == 'S') { // Start hold
        strip.SetPixelColor(lednumber, green);
        Serial.println(" (green)");
      }
      if (holdtype == 'P') { // Progress hold
        strip.SetPixelColor(lednumber, blue);
        Serial.println(" (blue)");
      }
      if (holdtype == 'E') { // End hold
        strip.SetPixelColor(lednumber, red);
        Serial.println(" (red)");
      }
      
      if (pos == -1) { // Last hold has been processed!
        strip.Show(); // Light up all hold (and additional) LEDs
        problemstring = ""; // Reset problem string
        useadditionalled = false; // Reset additional LED option
        state = 0; // Switch to state 0 (wait for new problem string or configuration)
        Serial.println("---------\n");
        break;
      }

      problemstring = problemstring.substring(pos+1, problemstring.length()); // Remove processed hold from string
    }
  }
}

I'm running out of ideas. haha. Hoping I am just overlooking something here.

1 Like

Schematics please. The powering of the project is interesting.

That example you linked sets the "max brightness" of each NeoPixel to 50 (out of 255) to keep new users (of NeoPixel) from frying their boards.

Here is a simulation of that link.

Hi, @onbelayclimbon
Welcome to the forum.

Forget the Bluetooth for now and make code that JUST controls the WS2811,
The neopixel library should have an example for you to use.

What model is the Arduino controller?
How many LEDs is in the strip?
What is your power Supply?

As ask previously;
Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:
PS. Do you have a DMM?

Thanks for the fast responses everyone!

To fill in some blanks

  1. Power supply is meanwell lpv-60-5
  2. Chip is Nano 33 Sense Rev2 BLE
  3. I have 4 strips of 50

I also tried sketching out how I have it all wired up. Hope it helps!

Thanks everyone

1 Like

Guess no one sees any obvious mistakes I made in wiring everything up? Wondering if there are any steps to troubleshoot further to help eliminate possible causes? (for example, is there a way to test the LEDs with a simpler setup to confirm they even light up?)

Hi,
I have requested that the moderators move your thread to the Nano 33 BLE Sense part of the forum.
There you may find members more familiar with the Nano 33.

Including Nano 33 in your subject would be advantageous as well. You can edit your subject line.

I am not familiar with that controller, its is 3V3 and also the Libraries may not run correctly with that controller.

Tom.. :smiley: :+1: :coffee: :australia:

Moved as requested.

Thanks so much! Sorry if I posted in wrong spot originally. Updating subject now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.