Ws2812 what are minimum values strip.bright and strip.color for minimum light?

Hello everyone,

Sorry for my bad English and mistakes.

About ws2812, what are the minimum values :

  • int B for strip.bright(B)
  • int C for :
    • strip.color(C,0,0)
    • strip.color(C,C,0)
    • strip.color(0,C,0)
    • strip.color(0,C,C)
    • strip.color(0,0,C)
    • strip.color(C,0,C)
    • strip.color(C,C,C)
      for a minimum of light ?

I think if B=60 and C=40, maybe with B=40 and C=60 or with B=50 and C=50, I get the same lighting?

I tried to find something with google, but nothing helps me.

I can write a sketch and modify each value of B and C separately, but 60 x 60 = 3,600 sketches to compile and test... tedious and very long work.

It is possible to put 2 nested loops (for change B and for change C, 0 to 60), but I don't imagine how can I see the values ​​that correspond to the minimum ignition.

Without any certainty, I think the best way would be a webserver for my esp, and from displayed webpage, clicking + or - with mouse to change B value and C value separately.
But today, I don't have enough knowledge to realize it.

Maybe someone has already written a similar sketch?

Thanks. Have a good day/night

it is. or put a rotary encoder to fine tune the values.

"minimum light" is a vague concept (depends if you are in the dark or in full sun for example) and the quality of your power supply... so it will be subject to your interpretation

The RGB ledstrips are mostly 8-bit. So you have 256 different values for each color.

The difference between off (value 0) and minimal light (value 1) is a big step in brightness.
The difference between bright values, say between 200 and 201 is not noticeable.

The Adafruit Neopixel library can set the overall brightness. You can calculate the resulting value.
Some think that by lowering the overall brightness, the brightness gap between value 0 and 1 can be made smaller, but the overall brightness is only in software. The ledstrip has still that gap.

The ways to fill the gap between off (value 0) and minimal (value 1) are:

  • Use a ledstrip with more than 8 bits.
  • Add a semi-transparent sheet in front of the ledstrips to dim everything.
  • Cheat a little by lowering the voltage for the ledstrip.

Can you tell what problem you are trying to solve ?

I use 13A / 5V reguled stabilised and filtred .
My ws2852 is 100 leds.

Minimum light is when led give very very very small light in dark black space.
It is the smaller value for B (bright) and the smaller value for C (color).

The value of one influences the value of the other.

Suppose I find that with B=20 and C=80.
With a larger B value and a smaller C value (or vice versa), I will get the same brightness.
How to know all the pairs (B, C) giving this same tiny luminosity?

You mix two different things. There is a hardware WS2812 ledstrip and there is a software Adafruit library. The hardware WS2812 ledstrip does not have a overall brightness setting.

The WS2812 has 8 bits for each color. A value of 0 turns it off and a value of 1 is the most dim brightness. There is nothing else to it. Really. Guaranteed. It is in the datasheet.

Can you show a minimal working sketch that shows the problem ? I have not heard of "strip.bright()" or "strip.color()" before. The C-language is case sensitive.

As I wrote before, the Adafruit Neopixel library can set a overall brightness. But that is just in the library, in software. If the resulting value for the ledstrip drops below 1, then that led is off.

There is more to the story. The FastLED library can dither colors to get between the integer values. That only works for short ledstrips. I don't know if the Neopixel library can dither.

I use the numbers to dictate brightness.

RGB 255,0,0 is red. 2,0,0 is still red but much dimmer.

As @Koepel mentioned, the Adafruit library can do lots of different things. Their uber guide is worth a read regarding overall Neopixel use and also best practices (connecting them correctly, etc)
https://learn.adafruit.com/adafruit-neopixel-uberguide

Bright and Color accept values ​​from 0 to 255.

To simplify, let's say it's a linear progression.
At 0 there is no shard and at 255 it is the maximum available.

Setting Bright to 255 will get me up to the maximum brightness available.
With Color at 255, I will have all the brightness that Bright offers me, which is 100% of the total brightness.
With color at 127, I will have 50% of the luminosity that Bright offers me, which is 50% of the total luminosity.

By setting Bright to 127, I will only have 50% brightness available.
With Color at 255, I will have all the brightness that Bright offers me, which is 50% of the total brightness.
With color at 127, I will have 50% of the luminosity that Bright offers me, or 25% of the total luminosity.

So Bright(255) Color(127) = Bright(127) Color(225) = 50% brightness.

What I'm looking for is the value of Bright and the value of Color, to have the lowest possible light, just before switching off.

And following the reasoning below, I would like to know all the pairs of values ​​for B and for C scattering the weakest possible light, just before the extinction.

Thanks for your suggestions.

Put in a number, if the number is to bright reduce the number till the number is the brightness you are looking for.

Example

255,0,0 too bright
254,0,0 still too bright
and so on and so forth.

I could do it for you, for a fee.

I wrote that, it is working well but not clean, no comment inside.

//https://github.com/fabriceDurand/esp_webserver

#include <WiFi.h>
const char* ssid =  "ssid";
const char* password = "pass";
#include <WebServer.h>

#include <Adafruit_NeoPixel.h>
#define LED_PIN 15
#define LED_COUNT 76
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

int value_B = 0,value_C = 0; // valeur de B bright et C color
int i = 0 , d = 10 , m = 20, s= 1 ;
//https://htmlbeaify.com
String head = "<!DOCTYPE html> <html lang='fr'> <head> <title>esp32 ws2812</title> <meta URL=http:/' charset='UTF-8' /> <style> a{text-decoration: none;} a div:hover{ background-color: blue; color:white;} table{width:100% ; height:100% ;  background-color: coral; } table, th, td {border: 1px solid black;} td { text-align: center; vertical-align: middle; font-size: 300%; padding-left:15px; height:30%; } </style> </head> <body> <table> <tr> <td  style=\"width:48%\" colspan = 4> <a href=\"/tm\"> <div><h3> B </h3></div> </a> </td> <td rowspan = 3 >&nbsp;</td> <td  style=\"width:48%\" colspan = 4> <a href=\"/tp\"><div><h3> C </h3></div></a> </td> </tr> <tr> <td colspan = 4>";
String mide ="</td><td colspan = 4>"; 
String foot = "</td> </tr> <tr> <td style=\"width:12%\"> <a href=\"/bmd\"><div><h3> - 10 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/bmu\"><div><h3> - 1 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/bpu\"><div><h3> + 1 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/bpd\"><div><h3> + 10 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/cmd\"><div><h3> - 10 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/cmu\"><div><h3> - 1 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/cpu\"><div><h3> + 1 </h3></div></a> </td> <td style=\"width:12%\"> <a href=\"/cpd\"><div><h3> + 10 </h3></div></a> </td> </tr> </table> </body> </html>";

WebServer server(80);

void ilumine()
{  
/*  
  strip.Color(255,   0,   0); // red
  strip.Color(  0, 255,   0); // green
  strip.Color(  0,   0, 255); // blue
  strip.Color(255, 255,   0); // yellow
  strip.Color(  0, 255, 255); // cyan
  strip.Color(255,   0, 255); // magenta
  strip.Color(255, 255, 255); // white
*/
  char message[60] = "";
  int i = value_C , m = i + 10 , s= 1 , pixel = 0;
        // variation lumiere
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i = value_C ; i < m ; i += s ) 
        { 
          strip.setPixelColor(pixel++, strip.Color( i,   0,   0));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "RED", pixel, value_B ,  i,   0,   0);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i =  value_C ; i < m ; i += s ) 
        { 
          strip.setPixelColor(pixel++, strip.Color( i,   i,   0));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "YEL", pixel, value_B ,  i,   i,   0);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i =  value_C ; i < m ; i += s ) 
        { strip.setPixelColor(pixel++, strip.Color( 0,   i,   0));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "GRE", pixel, value_B ,  0,   i,   0);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i =  value_C ; i < m ; i += s ) 
        { strip.setPixelColor(pixel++, strip.Color( 0,   i,   i));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "CYA", pixel, value_B ,  0,   i,   i);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i = value_C ; i < m ; i += s ) 
        { strip.setPixelColor(pixel++, strip.Color( 0,   0,   i));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "BLU", pixel, value_B ,  0,   i,   i);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i =  value_C ; i < m ; i += s ) 
        { strip.setPixelColor(pixel++, strip.Color( i,   0,   i));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "MAG", pixel, value_B ,  i,   0,   i);
          Serial.print (message);
        }
        Serial.print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        for( i =  value_C ; i < m ; i += s ) 
        { strip.setPixelColor(pixel++, strip.Color( i,   i,   i));
          sprintf(message,"\n%s | Pixel = %3d | Bright = %3d | Color( %3d , %3d, %3d )", "WHI", pixel, value_B ,  i,   i,   i);
          Serial.print (message);
        }
        strip.setBrightness(value_B); // Set BRIGHTNESS (max = 255)
        strip.show();
        Serial.println("\n===========================================================");
        Serial.print(" strip.setBrightness(");Serial.print(value_B);Serial.println(")"); 
        Serial.println("===============================================================");
 }
//#########################################################################
void Actions(int modif)
{  char message[60] = "";
   sprintf(message,"\n boutons B et C appuyés : %3d | %3d ", value_B, value_C );
   Serial.print (message);
   value_B += modif;
   value_B = (0 > value_B) ? 0 : (value_B > 255) ? 255 : value_B;
   value_C += modif;
   value_C = (0 > value_C) ? 0 : (value_C > 255) ? 255 : value_C;
   sprintf(message," devienent : %3d | %3d ", value_B, value_C );
   Serial.print (message);
   ilumine();
   homePage();
}   

void Action(String bouton, int modif, int *value)
{  char message[60] = "";
   sprintf(message,"\n bouton %s %3d appuyé : %3d ", bouton , modif , *value );
   Serial.print (message);
   *value += modif;
   *value = (0 > *value) ? 0 : (*value > 255) ? 255 : *value;
   sprintf(message," devient %3d", *value );
   Serial.print (message);
   
   ilumine();
   homePage();
}

void Action_bpu()
{  Action("B",  1, &value_B);
}

void Action_bpd()
{   Action("B", 10, &value_B);
}

void Action_bmu()
{   Action("B", -1, &value_B);
}

void Action_bmd()
{   Action("B",-10, &value_B);
}

void Action_cpu()
{   Action("C",  1, &value_C);
}

void Action_cpd()
{   Action("C", 10, &value_C);
}

void Action_cmu()
{   Action("C", -1, &value_C);
}

void Action_cmd()
{   Action("C",-10, &value_C);
}

void Action_tp()
{   Actions( 10);
}

void Action_tm()
{  Actions(-10);
}  

void pageIntrouvable()
{
    server.send(404, "text/plain", "404: page introuvable");
}

void colorWipe(uint32_t color, int wait) 
{  for(int i=0; i<strip.numPixels(); i++) 
  {
    strip.setPixelColor(i, color);      
    strip.show();                          
    delay(wait);                          
  }
}

void init_ws2812()
{ Serial.println("init ws2812");
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(200); // Set BRIGHTNESS to about 1/5 (max = 255)
  colorWipe(strip.Color(255,   0,   0), 10); // red
  colorWipe(strip.Color(  0, 255,   0), 10); // green
  colorWipe(strip.Color(  0,   0, 255), 10); // blue
  colorWipe(strip.Color(255, 255, 255), 10); // white
  colorWipe(strip.Color(  0,   0,   0), 10); // black
}

void homePage()
{
    strip.show();
//strip.fill(strip.Color(150,150,90),72,82);
    strip.setBrightness(2);
    strip.show();
  
    server.send(200, "text/html", head + String(value_B) + mide + String(value_C) + foot);
}
//////////////////////
void setup() 
{ 
    Serial.begin(115200);
    strip.begin();
    init_ws2812();
    WiFi.persistent(false);
    WiFi.begin(ssid, password);
    Serial.print("Tentative de connexion ~~");
  byte cli = false;
  uint32_t led_colo[] = {strip.Color(255,0,255),0};
  while (WiFi.status() != WL_CONNECTED) 
  {   Serial.print("~~");
      strip.fill(led_colo[cli],0,60);
      strip.show();
      cli = !cli;
      delay(500);   
  }
    Serial.print("\n Connexion etablie : ");
    Serial.println(WiFi.localIP());

    // à faire : affichage localIP sur ws2812 
    // blanc-vif pour le point, blanc doux pour 0, rouge pour centaines, vert pour dizaines, bleu pour unités, couleur vive = 5, couleur douce = unités
    // 192.168.0.2 = rouge vert-vif vert vert vert vert bleu bleu blanc-vif rouge vert-vif vert bleu-vif bleu bleu bleu blanc-vif blanc-doux blanc-vif bleu bleu

    server.on("/", homePage);
    server.on("/bpu", Action_bpu);
    server.on("/bpd", Action_bpd);
    server.on("/bmu", Action_bmu);
    server.on("/bmd", Action_bmd);
    server.on("/cpu", Action_cpu);
    server.on("/cpd", Action_cpd);
    server.on("/cmu", Action_cmu);
    server.on("/cmd", Action_cmd);
    server.on("/tp",  Action_tp);
    server.on("/tm",  Action_tm);
    server.onNotFound(pageIntrouvable);
    server.begin();

    Serial.println("Serveur web disponible!");

}

void loop() 
{
  server.handleClient();
}

If you want, you can rewrite it much more better (optimized) and please give me back it.
Thank you.

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