playing with neopixels
I did some playing around with Diba’s Adafruit neopixels! I definitely ran into some tougher points, some points of new understanding, etc. I wanted to play with brightness and combining different colors. I created a few functions and tested them out. I had some trouble with how exactly the data types work and definitely had to adjust some of my functions to make them work the way I wanted to. Also, I learned that delays are crucial and for loops are fun! I consulted a lot of the strandtest code and even used some of it in some of my functions. Overall it was somewhat challenging but I found them very fun to work with!
Here are some of my functions:
void threeColPattern(int wait, uint32_t col1, uint32_t col2, uint32_t col3) {
//input of delay time and three different colors
//inspired by colorWipe function from strandtest
for (int i = 0; i < strip.numPixels(); i++) {
if ((i % 2) == 0) {
//2nd color
strip.setPixelColor(i, col2);
strip.show();
delay(wait);
} else if ((i % 3) == 0) {
//3rd color
strip.setPixelColor(i,col3);
strip.show();
delay(wait);
} else {
//1st color
strip.setPixelColor(i,col1);
strip.show();
delay(wait); }}}
void threeColorMix(int col1[], int col2[], int col3[], int wait) {
int r = (col1[0] + col2[0] + col3[0]) / 3;
int g = (col1[1] + col2[1] + col3[1]) /3;
int b = (col1[2] + col1[2] + col3[2]) /3;
int newCol = strip.Color(g, r, b, 50);
colorWipe(newCol, wait); }
void increaseBrightness(uint8_t min, uint8_t max, int r, int g, int b) {
//makes the brightness go up and then back down
colorWipe(strip.Color(255,0,0), 20);
for (int j = min; j < max; j++) {
for (int i = 0; i< strip.numPixels(); i++) {
strip.setBrightness(j);
}
delay(20);
}
for (int k = max; k > min; k--) {
for (int l = 0; l < strip.numPixels(); l++) {
strip.setBrightness(k);
}
}
delay(20);}
Here’s a video, it shows the changing brightness, the pattern, and the mixed colors!