Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
NeoPatterns Pixels(43, 5, NEO_GRB + NEO_KHZ800, &PixelsComplete);
// Initialize all the pixelStrips
Pixels.begin();
// Kick off a pattern
Pixels.Fade(Pixels.Color(0,0,0), Pixels.Color(255,128,0), 100, 1); // black to orange
Re: NEOPIXEL brightness control
for(int rep = 0; rep <5; rep++){ "breathing code"}
Re: NEOPIXEL brightness control
If I load this code up to the arduino, the arduino does not respond to any other inputs from a button or a rotary encoder. Why is it like this and how do I get out of that loop?
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
#define TOTAL_LEDS 60
void loop()
{
breathe(255, 0.008, 5);
}
void breathe(float MaximumBrightness, float SpeedFactor, float StepDelay)
{
// Make the lights breathe
for (int i = 0; i < 65535; i++) {
// Intensity will go from 10 - MaximumBrightness in a "breathing" manner
float intensity = MaximumBrightness /2.0 * (1.0 + sin(SpeedFactor * i));
strip.setBrightness(intensity);
// Now set every LED to that color
for (int ledNumber=0; ledNumber<TOTAL_LEDS; ledNumber++) {
strip.setPixelColor(ledNumber, 0, 0, 255);
}
strip.show();
//Wait a bit before continuing to breathe
delay(StepDelay);
}
}
#define TOTAL_LEDS 60
void loop()
{
breathe(strip.Color(255, 0, 0), 255, 0.008, 5);
breathe(strip.Color(0, 255, 0), 255, 0.008, 5);
breathe(strip.Color(0, 0, 255), 255, 0.008, 5);
}
void breathe(uint32_t color, float MaximumBrightness, float SpeedFactor, float StepDelay)
{
// Make the lights breathe
for (int i = 0; i < 65535; i++) {
// Intensity will go from 10 - MaximumBrightness in a "breathing" manner
float intensity = MaximumBrightness /2.0 * (1.0 + sin(SpeedFactor * i));
strip.setBrightness(intensity);
// Now set every LED to that color
for (int ledNumber=0; ledNumber<TOTAL_LEDS; ledNumber++) {
strip.setPixelColor(ledNumber, color);
}
strip.show();
//Wait a bit before continuing to breathe
delay(StepDelay);
}
}
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
void loop() {
// Breathing effect
int breathIng = 0;
for (breathIng; breathIng < 5; breathIng ++) {
for (int i = 0; i < 65535; i++) {
// Intensity will go from 10 - MaximumBrightness in a "breathing" manner
float intensity = MaximumBrightness / 2.0 * (1.0 + sin(SpeedFactor * i));
pixels.setBrightness(intensity);
// Now set every LED to that color
for (int ledNumber = 0; ledNumber < NUMPIXELS; ledNumber++) {
pixels.setPixelColor(ledNumber, REDo);
}
pixels.show();
//Wait a bit before continuing to breathe
delay(StepDelay);
}
}
Re: NEOPIXEL brightness control
#include <Adafruit_NeoPixel.h>
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
#include <avr/power.h>
#endif
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(40, PIN);
uint32_t color = (0,0,0); // Start dark
#define TOTAL_LEDS 40
void setup() {
// put your setup code here, to run once:
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
if(F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
strip.begin();
strip.setBrightness(0); // 1/3 brightness
strip.show();
}
void loop() {
// 0.08 speedfactor is fast blinking
// 0.018 is medium fast
uint8_t r = random(0x22, 0xff);
uint8_t g = random(0x22, 0xff);
uint8_t b = random(0x22, 0xff);
breathe(strip.Color(r, g, b), 50, 0.008, 5);
// breathe(strip.Color(0, 255, 0), 105, 0.010, 5);
// breathe(strip.Color(0, 0, 255), 105, 0.010, 5);
}
void breathe(uint32_t color, float MaximumBrightness, float SpeedFactor, float StepDelay)
{
float intensity;
// Make the lights breathe
// 5530 = 8 iterations
for (int i = 0; i < 2200; i++) {
// Intensity will go from 10 - MaximumBrightness in a "breathing" manner
float intensity = MaximumBrightness /2.0 * (1.0 + sin(SpeedFactor * i));
strip.setBrightness(intensity);
// Now set every LED to that color
for (int ledNumber=0; ledNumber<TOTAL_LEDS; ledNumber++) {
strip.setPixelColor(ledNumber, color);
}
strip.show();
//Wait a bit before continuing to breathe
delay(StepDelay);
}
}
Re: NEOPIXEL brightness control
#include "Adafruit_NeoPixel.h"
#include "SPI.h"
//Demonstrates "breathing" effect on NeoPixel Strip
#define LED_PIN 6
#define N_LEDS 16
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
uint8_t LED_Breathe_Table[] = { 80, 87, 95, 103, 112, 121, 131, 141, 151, 161, 172, 182, 192, 202, 211, 220,
228, 236, 242, 247, 251, 254, 255, 255, 254, 251, 247, 242, 236, 228, 220, 211,
202, 192, 182, 172, 161, 151, 141, 131, 121, 112, 103, 95, 87, 80, 73, 66,
60, 55, 50, 45, 41, 38, 34, 31, 28, 26, 24, 22, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 24, 26, 28,
31, 34, 38, 41, 45, 50, 55, 60, 66, 73 };
#define BREATHE_TABLE_SIZE (sizeof(LED_Breathe_Table))
#define BREATHE_CYCLE 6000 /*breathe cycle in milliseconds*/
#define BREATHE_UPDATE (BREATHE_CYCLE / BREATHE_TABLE_SIZE)
void setup() {
// Start up the LED strip
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop() {
int cycle;
for (cycle=0; cycle < 4; cycle++) {
uniformBreathe(LED_Breathe_Table, BREATHE_TABLE_SIZE, BREATHE_UPDATE, 256, 256, 256);
}
for (cycle=0; cycle < 4; cycle++) {
sequencedBreathe(LED_Breathe_Table, BREATHE_TABLE_SIZE, BREATHE_UPDATE, 256, 256, 256);
}
}
void uniformBreathe(uint8_t* breatheTable, uint8_t breatheTableSize, uint16_t updatePeriod, uint16_t r, uint16_t g, uint16_t b)
{
int i;
uint8_t breatheIndex = 0;
uint8_t breatheRed;
uint8_t breatheGrn;
uint8_t breatheBlu;
for (breatheIndex = 0; breatheIndex < breatheTableSize; breatheIndex++) {
for (i=0; i < strip.numPixels(); i++) {
breatheRed = (r * breatheTable[breatheIndex]) / 256;
breatheGrn = (g * breatheTable[breatheIndex]) / 256;
breatheBlu = (b * breatheTable[breatheIndex]) / 256;
strip.setPixelColor(i, breatheRed, breatheGrn, breatheBlu);
}
strip.show(); // write all the pixels out
delay(updatePeriod);
}
}
void sequencedBreathe(uint8_t* breatheTable, uint8_t breatheTableSize, uint16_t updatePeriod, uint16_t r, uint16_t g, uint16_t b)
{
int i;
uint8_t breatheIndex = 0;
uint8_t breatheRed;
uint8_t breatheGrn;
uint8_t breatheBlu;
uint8_t sequenceIndex;
for (breatheIndex = 0; breatheIndex < breatheTableSize; breatheIndex++) {
for (i=0; i < strip.numPixels(); i++) {
sequenceIndex = (breatheIndex + (i*4)) % breatheTableSize;
breatheRed = (r * breatheTable[sequenceIndex]) / 256;
breatheGrn = (g * breatheTable[sequenceIndex]) / 256;
breatheBlu = (b * breatheTable[sequenceIndex]) / 256;
strip.setPixelColor(i, breatheRed, breatheGrn, breatheBlu);
}
strip.show(); // write all the pixels out
delay(updatePeriod);
}
}
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control
Re: NEOPIXEL brightness control