WS2812B (1 Viewer)

Kotik

MP Donator
  • Premium Supporter
  • March 19, 2009
    699
    485
    Athens
    Home Country
    Greece Greece
    Hello guys.
    For a long time now i was thinking of getting myself a new project :)

    Well recently i decided to start the ambilight project.

    I ordered myself an arduino uno v3, a 5v 20a power supply and 3 meters of WS2812B (60 LEDS per meter, so a total of 180 LEDS).
    Everything arrived and i decided to start working on it.
    1st i connected all the cables and made sure my power supply is giving out 5 volts exactly. Then i connected the UNO v3 to my PC and installed 2 libraries on it. The latest Neopixel library downloaded from here and the FastLed library version 3.0.3 downloaded from here, ran tests from both libraries and they look great :)
    Next step was to find the right sketch, i am amazed how hard it is to find one that is working, i am currently using this
    #include "FastLED.h"

    // How many leds are in the strip?
    #define NUM_LEDS 180

    // Data pin that led data will be written out over
    #define DATA_PIN 6

    // This is an array of leds. One item for each led in your strip.
    CRGB leds[NUM_LEDS];

    void setup(){
    Serial.begin(115200);
    //sanity check delay - allows reprogramming if accidently blowing power w/leds
    delay(3000);

    // Change this to match your led strip
    // Uncomment one of the following lines for your leds arrangement.
    // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
    // FastLED.addLeds<NEOPIXEL, DATA_PIN, GRB>(leds, NUM_LEDS);

    // blank out the LEDs
    setupLEDs();
    }

    int readByte(){
    while(Serial.available()==0){
    }
    return Serial.read();
    }

    // show colored LEDs for 500ms then blanks out ready to go
    void setupLEDs(){
    memset(leds,150, sizeof(leds));
    FastLED.show();
    delay(500);
    memset(leds,0, sizeof(leds));
    FastLED.show();
    }

    void loop(){
    if(readByte() == 0xFF){
    if(readByte() == 0x00){
    if(readByte() == 0x00){
    int channels = readByte();
    for(int channel=0; channel<channels; channel++){
    leds[channel].r = readByte();
    leds[channel].g = readByte();
    leds[channel].b = readByte();
    }
    FastLED.show();
    }
    }
    }
    }
    After i was done with the sketch i uploaded it to my UNO v3 and run Atmowin (version 1.0.0.8 downloaded from our forums) with settings set to "Live" for testing purposes BUT when i open some YouTube ambilight demo videos my LEDS go crazy!!!
    Each time there is fast color changing my LEDS start to blink and flicker like crazy.They are working ok when the video has smooth color changes but when the video colors start changing and blinking the LEDS acts as if they cannot keep up and start flashing random colors, sometimes they just hang out and i have to restart them, sometimes they just recover a couple of seconds later by themselves.Still they are working perfectly with the FastLed or Neopixel tests. What can be wrong guys? I tried different settings, i tried adding a 2nd power line at the end of the strip to make it more stable and this actually made it worse... i run out of ideas, please help :)
    PS. Forgot to mention that i have a 16v 2200μf capacitor installed right at the power supply +/- 5v output and i also have a 450ohm resistance installed at PIN6 of UNO v3
    PS2. The video that make my setup behave all nuts is https://www.youtube.com/watch?v=jV8IFZ5Sa_k.
     
    Last edited:

    Quarter

    MP Donator
  • Premium Supporter
  • June 21, 2010
    722
    138
    Queenstown
    Home Country
    New Zealand New Zealand
    I have the same setup 188 LEDs and using FastLED, had a few problems but trial and error I got there. I'm not using any capacitors or resistors hasn't caused any problems yet. Are you using Atmoduinov2?
     

    Quarter

    MP Donator
  • Premium Supporter
  • June 21, 2010
    722
    138
    Queenstown
    Home Country
    New Zealand New Zealand
    Try raising the baudrate. 115200 doesnt seem enough.

    188 (leds) * 24 (bits) * 30 (fps) = 135360bps
    Not even considering start and stop bits :).

    OP has 180, I have 188 it seems to be working ok at 115200, but that's a good pointer for me thanks

    Ps the max I can get out of the Arduino uno is 128000.
     
    Last edited:

    Kotik

    MP Donator
  • Premium Supporter
  • March 19, 2009
    699
    485
    Athens
    Home Country
    Greece Greece
    Are you using Atmoduinov2?

    I tried to use Atmoduino v2 but it just didn't work. Atmowin wasn't even communicating with my LEDS with Atmoduino v2.

    Any ideas?
    Can u also post me the sketch u are using?

    Try raising the baudrate. 115200 doesnt seem enough.

    188 (leds) * 24 (bits) * 30 (fps) = 135360bps
    Not even considering start and stop bits :).

    Thanx for the tip, i will try it.

    Besides changing it in Atmowin and the sketch, do u suggest changing the baudrate on the usb port itself in device manager?
     

    Kotik

    MP Donator
  • Premium Supporter
  • March 19, 2009
    699
    485
    Athens
    Home Country
    Greece Greece
    Besides changing it in Atmowin and the sketch, do u suggest changing the baudrate on the usb port itself in device manager?
    Nope, only Sketch and AtmoWin.
    Will try it right away and report you the results
    Thank you very much for the help. Changing the baudrate in AtmoWin and my sketch finally solved the issue.

    Do u suggest changing it any higher? i got it on 230400 right now.

    Any idea as to why i cannot use Atmoduinov2 with my setup?
     
    Last edited:

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Do u suggest changing it any higher? i got it on 230400 right now.
    Well, we can do the math further. Lets assume 60fps is the highest framerate you will ever use/need, then

    180*24*60 = 259200

    Again, not counting any start and stop bits. So yeah, probably better to go higher if that works. Should be no problem with an Uno though.


    Any idea as to why i cannot use Atmoduinov2 with my setup?
    Nope, im not using an arduino for my ambilight. But as this has come up multiple times over the time, i will have a look at that at some point. However currently my only arduino is being used for another project im working on and hooked up to a breadboard and stuff, so dont really want to rip that all apart right now.
     

    Kotik

    MP Donator
  • Premium Supporter
  • March 19, 2009
    699
    485
    Athens
    Home Country
    Greece Greece
    Well, we can do the math further. Lets assume 60fps is the highest framerate you will ever use/need, then

    180*24*60 = 259200

    Again, not counting any start and stop bits. So yeah, probably better to go higher if that works. Should be no problem with an Uno though.

    Will try to increase it and will let u know how it went.

    Offtopic, do u have any personal preference regarding Arduino LED libraries? would u pick FastLED over Neopixel? Do u use some specific sketch that u could recommend? Could u elaborate a bit on this topic since u seem to be familiar with the subject.

    Again thank you for your time and effort i highly appreciate it.
     

    Lightning303

    MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    Offtopic, do u have any personal preference regarding Arduino LED libraries? would u pick FastLED over Neopixel?
    I havnt actually tried the Neopixel lib and cant say anything about it. However im using the FastLED lib in another project of mine (https://forum.team-mediaportal.com/...8266-wifi-module-and-ws2812b-rgb-leds.129229/). There isnt really an objective reason for me prefering FastLED, as i have never compared the two. I just felt like going with FastLED ;).


    Do u use some specific sketch that u could recommend? Could u elaborate a bit on this topic since u seem to be familiar with the subject.
    As i said, i actually am not using an arduino for my ambilight like you want to do. So cant say much about that. But if the sketch from your initial post works (+ the baud changes), i would recommend using that one.
     

    Users who are viewing this thread

    Top Bottom