Re: NEOPIXEL brightness control
strip.setPixelColor(i, (0, 0, 127));
strip.setPixelColor(i, (0, 63, 0)); //1/4 bright green
strip.setPixelColor(i, (255, 0, 0)); //full-bright red
strip.setPixelColor(i, (0, 255, 255)); //full-bright cyan
strip.setPixelColor(i, (127, 127, 0)); //half-bright yellow
strip.setPixelColor(i, (255, 192, 255)); //orange
strip.setPixelColor(i, (63, 63, 63)); //1/4-bright white
Re: NEOPIXEL brightness control
void loop()
{
strip.setBrightness(255);
strip.setPixelColor(n, 255,0,100);
strip.show();
delay(1000);
strip.setBrightness(50);
strip.show();
delay(1000);
}
Re: NEOPIXEL brightness control
This lets you choose your overall pixel colour and then apply effects like "breathing" (slowly fading the brightness up and down) without having to recalculate values for red, green and blue for each step of the fade.
Re: NEOPIXEL brightness control
uint16_t brightness;
void loop()
{
brightness = 255;
strip.setPixelColor(n, (brightness*255/255) , (brightness*0/255), (brightness*100/255));
strip.show();
delay(1000);
brightness = 50;
strip.setPixelColor(n, (brightness*255/255) , (brightness*0/255), (brightness*100/255));
strip.show();
delay(1000);
}
Mild Lee Interested wrote:What I would really like is a strip.setBrightness() command that can be applied to an individual pixel, rather than the whole strip...
Adafruit_NeoPixel::setPixelColor( uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint16_t brightness) {
setPixelColor(n, (brightness*r/255) , (brightness*g/255), (brightness*b/255));
}
void loop()
{
strip.setPixelColor(n, 255,0,100, 255);
strip.show();
delay(1000);
strip.setPixelColor(n, 255,0,100, 50);
strip.show();
delay(1000);
}
Re: NEOPIXEL brightness control
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
int fadeControl = 255;//will hold the current brightness level
int fadeDirection = -1;//change sigen to fade up or down
int fadeStep = 10;//delay between updates
void setup()
{
strip.begin();
strip.show();
}
void loop()
{
strip.setPixelColor(0, 255, 192, 255);//set the pixel colour
strip.setBrightness(fadeControl);//set the pixel brightness
strip.show();
fadeControl = fadeControl + fadeDirection;//increment the brightness value
if (fadeControl <0 || fadeControl > 255)
//If the brightness value has gone past its limits...
{
fadeDirection = fadeDirection * -1;//change the direction...
fadeControl = fadeControl + fadeDirection;//...and start back.
}
delay(fadeStep);//wait a bit before doing it again.
}
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
void setPixelColor( uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint16_t brightness) {
strip.setPixelColor(n, (brightness*r/255) , (brightness*g/255), (brightness*b/255));
}
setPixelColor( pixelNumber, rValue, gValue, bValue, brightness );
Re: NEOPIXEL brightness control
chargerdude70 wrote:How or where in the library would this code that was posted earlier be added?
setPixelColor( uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint16_t brightness)
Re: NEOPIXEL brightness control
// Set pixel color from 'packed' 32-bit RGB color:
void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint32_t c) {
if(n < numLEDs) {
uint8_t
r = (uint8_t)(c >> 16),
g = (uint8_t)(c >> 8),
b = (uint8_t)c;
if(brightness) { // See notes in setBrightness()
r = (r * brightness) >> 8;
g = (g * brightness) >> 8;
b = (b * brightness) >> 8;
}
uint8_t *p = &pixels[n * 3];
#ifdef NEO_RGB
if((type & NEO_COLMASK) == NEO_GRB) {
#endif
*p++ = g;
*p++ = r;
#ifdef NEO_RGB
} else {
*p++ = r;
*p++ = g;
}
#endif
*p = b;
}
}
//Set pixel brightness individually
void setPixelColor( uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint16_t brightness) {
strip.setPixelColor(n, (brightness*r/255) , (brightness*g/255), (brightness*b/255));
}
void
begin(void),
show(void),
setPin(uint8_t p),
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
setPixelColor(uint16_t n, uint32_t c),
setPixelColor( uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint16_t brightness),
setBrightness(uint8_t);
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
setPixelColor(uint16_t n, uint32_t c, uint16_t brightness),
// Set each pixel brightness individually using uint32_t
void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint32_t c, uint16_t brightness) {
setPixelColor(n, (brightness*r/255) , (brightness*g/255), (brightness*b/255));
}
Re: NEOPIXEL brightness control
chargerdude70 wrote:when I add the code to the files, I get indivindual errors after compiling a sketch stating..........NeoPixel.cpp920: r, g, b was not declared in this scope
Re: NEOPIXEL brightness control