Results 1 to 3 of 3

Thread: Arduino, 60 LED serial light string not working.

  1. #1
    Join Date
    Nov 2018
    Posts
    9
    Post Thanks / Like

    Default Arduino, 60 LED serial light string not working.

    I downloaded the program by Sloan and Hunt (from this website), where they showed how to run Vixen with Arduino using the Generic Serial connection. The program compiles to an UNO without issue.
    I then configured Vixen according to the directions given, and also previous testing I did with the same UNO but through a MCP23017 port expander.

    So why doesn't my current setup work? I have the string connected to DIO pin 6 of the UNO and separate 5V power supply with 470 ohm resistor in series and 1000 uFd cap across power supply. When I do a Vixen Preview (to light up one channel/pixel/LED/element) I get nothing. Whereas when I did this through my port expander, it worked as advertised.

    If I put a 6V supply on instead of the 5V, all 60 LEDs blink in semi-random pattern in blue and red (no green), but all at the same time, like some kind of self-test. Maybe it's a noisy 6V wall-wart.
    I've attached screen prints of my Vixen config and included the Arduino program.
    Code:
    /*
    
    Vixen Lights 3.x - Arduino Generic Serial for Addressable Pixels
    
    Using this code is pretty straight forward, simply hookup your one wire (WS2811 or WS2812) data line to pin 6 of your Arduino
    and upload this code.  Make sure you have properly installed the FastLED library from http://fastled.io Once you are done, simply
    power your Pixel strips from an external power supply.  Next configure a Generic Serial Controller inside of Vixen Lights 3.x and 
    add 3 x pixels for the number of channels.  Configure the Generic Serial Controller to use 115200, 8, none, and 1.  Then create
    your element and add "Multiple Items (1 x number of pixels).  Finally select your pixel elements and set them as RGB pixels before
    patching them to the controler outputs.  You should now be ready to begin testing.
    
    For a complete tutorial check out blog.huntgang.com
    
    Created   November 8th, 2014
    By        Richard Sloan - www.themindfactory.com
    And       David Hunt - blog.huntgang.com
    Version   1.4
    
    */
    #include <FastLED.h>
    // Sets the maximum number of LEDs that this code will handle to avoid running out of memory
    #define NUM_LEDS 60
    // Sets the pin which is used to connect to the LED pixel strip
    #define DATA_PIN 6
    CRGB leds[NUM_LEDS];
    
    void setup() {
      // Define the speed of the serial port
      Serial.begin(115200);
    }
    void loop() {
      // Set some counter / temporary storage variables
      int cnt;
      unsigned int num_leds;
      unsigned int d1, d2, d3;
    
      // Begin an endless loop to receive and process serial data
      for(;;) {
        // Set a counter to 0.  This couter keeps track of the pixel colors received.
        cnt = 0;
        //Begin waiting for the header to be received on the serial bus
        //1st character
        while(!Serial.available());
          if(Serial.read() != '>') {
            continue;
            }
        //second character
        while(!Serial.available());
          if(Serial.read() != '>') {
            continue;
            }
        //get the first digit from the serial bus for the number of pixels to be used
        while(!Serial.available());
          d1 = Serial.read();
        //get the second digit from the serial bus for the number of pixels to be used
        while(!Serial.available());
          d2 = Serial.read();
        //get the third digit from the serial bus for the number of pixels to be used
        while(!Serial.available());
          d3 = Serial.read();
        //get the end of the header
        while(!Serial.available());
          if(Serial.read() != '<') {
            continue;
            }
        while(!Serial.available());
          if(Serial.read() != '<') {
            continue;
            }
        // calculate the number of pixels based on the characters provided in the header digits
        num_leds = (d1-'0')*100+(d2-'0')*10+(d3-'0');
        // ensure the number of pixels does not exceed the number allowed
        if(num_leds > NUM_LEDS) {
          continue;
          }
        // Let the FastLED library know how many pixels we will be addressing
        FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, num_leds);
        // Loop through each of the pixels and read the values for each color
        do {
          while(!Serial.available());
            leds[cnt].r = Serial.read();
          while(!Serial.available());
            leds[cnt].g = Serial.read();
          while(!Serial.available());
            leds[cnt++].b = Serial.read();
          } 
        while(--num_leds);
        // Tell the FastLED Library it is time to update the strip of pixels
        FastLED.show();
        // WOO HOO... We are all done and are ready to start over again!
        }
    }
    I bought the serial LED string (60 RGB per length) from Adafruit awhile ago...never used it until now.
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,357
    Post Thanks / Like

    Default Re: Arduino, 60 LED serial light string not working.

    This code should be working. Although some newer versions of arduino do not allow an infinite main loop. They depend on the loop returning to allow the supporting code a chance to run. That may or may not be the issue here. Does the Uno have a 2nd serial port you can use for debugging? Most likely you are not sending a valid header.


    2018 - Moving and going to visit my Daughter in New Zealand. Most likely I will be dark or nearly dark, Some static stuff that is simple to put up.

  3. #3
    Join Date
    Nov 2018
    Posts
    9
    Post Thanks / Like

    Default Re: Arduino, 60 LED serial light string not working.

    I did more experimenting, using a different program, from Adafruit, that does a lot of testing, from light chasing to fading and color mixing.

    It does this but only for ONE PIXEL, that is, LED#0 (or 1 depending on your logic). The other 59 don't light up, yet I know they work from previous experiments.

    I'll ask Adafruit, see what they say.

    Here's the Adafruit program for interest sake:
    HTML Code:
    #include <Adafruit_NeoPixel.h>
    
    #define PIN 6
    
    // Parameter 1 = number of pixels in strip
    // Parameter 2 = pin number (most are valid)
    // Parameter 3 = pixel type flags, add together as needed:
    //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
    //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
    //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
    //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
    
    void setup() {
      strip.begin();
      strip.show(); // Initialize all pixels to 'off'
    }
    
    void loop() {
      // Some example procedures showing how to display to the pixels:
      colorWipe(strip.Color(255, 0, 0), 50); // Red
      colorWipe(strip.Color(0, 255, 0), 50); // Green
      colorWipe(strip.Color(0, 0, 255), 50); // Blue
    
      // Send a theater pixel chase in...
      theaterChase(strip.Color(127, 127, 127), 50); // White
      theaterChase(strip.Color(127,   0,   0), 50); // Red
      theaterChase(strip.Color(  0,   0, 127), 50); // Blue
    
      rainbow(20);
      rainbowCycle(20);
      theaterChaseRainbow(50);
    }
    
    // Fill the dots one after the other with a color
    void colorWipe(uint32_t c, uint8_t wait) {
      for(uint16_t i=0; i<strip.numPixels(); i++) {
          strip.setPixelColor(i, c);
          strip.show();
          delay(wait);
      }
    }
    
    void rainbow(uint8_t wait) {
      uint16_t i, j;
    
      for(j=0; j<256; j++) {
        for(i=0; i<strip.numPixels(); i++) {
          strip.setPixelColor(i, Wheel((i+j) & 255));
        }
        strip.show();
        delay(wait);
      }
    }
    
    // Slightly different, this makes the rainbow equally distributed throughout
    void rainbowCycle(uint8_t wait) {
      uint16_t i, j;
    
      for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
        for(i=0; i< strip.numPixels(); i++) {
          strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
        }
        strip.show();
        delay(wait);
      }
    }
    
    //Theatre-style crawling lights.
    void theaterChase(uint32_t c, uint8_t wait) {
      for (int j=0; j<10; j++) {  //do 10 cycles of chasing
        for (int q=0; q < 3; q++) {
          for (int i=0; i < strip.numPixels(); i=i+3) {
            strip.setPixelColor(i+q, c);    //turn every third pixel on
          }
          strip.show();
    
          delay(wait);
    
          for (int i=0; i < strip.numPixels(); i=i+3) {
            strip.setPixelColor(i+q, 0);        //turn every third pixel off
          }
        }
      }
    }
    
    //Theatre-style crawling lights with rainbow effect
    void theaterChaseRainbow(uint8_t wait) {
      for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
        for (int q=0; q < 3; q++) {
            for (int i=0; i < strip.numPixels(); i=i+3) {
              strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
            }
            strip.show();
    
            delay(wait);
    
            for (int i=0; i < strip.numPixels(); i=i+3) {
              strip.setPixelColor(i+q, 0);        //turn every third pixel off
            }
        }
      }
    }
    
    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
      if(WheelPos < 85) {
       return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
      } else if(WheelPos < 170) {
       WheelPos -= 85;
       return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
      } else {
       WheelPos -= 170;
       return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
      }
    }

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •