AmbiLight with Arduino Nano V3 + WS2812B Led Setup Programmation

HI,

I've follow this video tutorial about my setup :

I follow everything but it's now perfect because i have two issue.

Some flickering happear on the LEDs, i just read that maybe it's the 470 Ohm resistor can help. I will try that but my main problem are these : (see attachment)

I have more Led on the Left Side than the right side;
Due to my monitor configuration, i have 25 leds into the left side, and 23 on the right side. Bottom and top have a total of 41 each, which results by 130 leds in my project.

I have no way to balance that in the Arduino project and also in AmbiBox.

Here are the code of the arduino project :

#include <bitswap.h>
#include <chipsets.h>
#include <color.h>
#include <colorpalettes.h>
#include <colorutils.h>
#include <controller.h>
#include <cpp_compat.h>
#include <dmx.h>
#include <FastLED.h>
#include <fastled_config.h>
#include <fastled_delay.h>
#include <fastled_progmem.h>
#include <fastpin.h>
#include <fastspi.h>
#include <fastspi_bitbang.h>
#include <fastspi_dma.h>
#include <fastspi_nop.h>
#include <fastspi_ref.h>
#include <fastspi_types.h>
#include <hsv2rgb.h>
#include <led_sysdefs.h>
#include <lib8tion.h>
#include <noise.h>
#include <pixelset.h>
#include <pixeltypes.h>
#include <platforms.h>
#include <power_mgt.h>



#define NUM_LEDS 130 // Nombre de LEDs de votre projet 
#define DATA_PIN 5 // Pin utilisé pour la gestion de la bande de led
#define BRIGHTNESS 96 // Luminosité max
#define SPEED 1000000 // Vitesse de transmission

uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i;

CRGB leds[NUM_LEDS];

void setup()
{

// pinMode(GROUND_PIN, OUTPUT);
  // digitalWrite(GROUND_PIN, LOW);
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  //FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  //FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);

 FastLED.setCorrection(TypicalSMD5050);

  Serial.begin(SPEED);
  Serial.print("Ada\n"); // Send "Magic Word" string to host

}

void loop() {
  // wait for first byte of Magic Word
  
  for(i = 0; i < sizeof prefix; ++i) {
    waitLoop: 
    while (!Serial.available());
    if (prefix[i] == Serial.read()) continue;
    i = 0;
    goto waitLoop;
  }

  // Hi, Lo, Checksum
  while (!Serial.available());
  hi = Serial.read();
  while (!Serial.available());
  lo = Serial.read();
  while (!Serial.available());
  chk = Serial.read();

  // if checksum does not match go back to wait
  if (chk != (hi ^ lo ^ 0x55)) {
    i = 0;
    goto waitLoop;
  }

  Serial.readBytes((char*)leds, NUM_LEDS*3);

  // shows new values
 FastLED.show();
}

Also, the speed and color seem's to not really perfectly match what i've on screen.

I don't know how to resolve the LED configurations and also the flickering issue.

Thanks for help.

2018-09-26_11h45_32.png

2018-09-26_11h52_11.png

I'm curious why you have included about a thousand libraries, none of which appear necessary for your code other than FastLED.h.

Also, you didn't use {} for your while-statements and put a ; directly after them, so I doubt they're executing correctly.

Lastly, goto is almost never used for a reason.

I've just copy/paste the code i've found. For now, i have no experience in coding. Except HTML/CSS.

Tell me what code to remove and i will remove.

Thanks for your Reply silly_cone.

Gotcha.

All I did here was cleaned up the library declarations, your setup() function, and edited your while-statements to have the proper opening and closing {}'s.

I did nothing in regards to the actual performance of your program, but I suspect there is still plenty that needs to be addressed (like how you declare your array, for example).

#include <FastLED.h>

#define NUM_LEDS 130 // Nombre de LEDs de votre projet 
#define DATA_PIN 5 // Pin utilisé pour la gestion de la bande de led
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define BRIGHTNESS 96 // Luminosité max
#define FRAMES_PER_SECOND  30 
#define SPEED 1000000 // Vitesse de transmission

uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i;

CRGB leds[NUM_LEDS];

void setup()
{
//pinMode(GROUND_PIN, OUTPUT);
//digitalWrite(GROUND_PIN, LOW);
  LEDS.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS).setCorrection( TypicalLEDStrip );

  Serial.begin(SPEED);
  Serial.print("Ada\n"); // Send "Magic Word" string to host
}

void loop() {
  // wait for first byte of Magic Word
  
  for(i = 0; i < sizeof(prefix); i++) {
    waitLoop: 
    while (!Serial.available()){
      if (prefix[i] == Serial.read()) continue;
      i = 0;
    }
    goto waitLoop;
  }

  // Hi, Lo, Checksum
  while (!Serial.available()){
    hi = Serial.read();
  }
  
  while (!Serial.available()){
    lo = Serial.read();
  }
  
  while (!Serial.available()){
    chk = Serial.read();
  }

  // if checksum does not match go back to wait
  if (chk != (hi ^ lo ^ 0x55)) {
    i = 0;
    goto waitLoop;
  }

  Serial.readBytes((char*)leds, NUM_LEDS*3);

  // shows new values
 FastLED.show();
}