// Call the flag colors function for the country or people
// from the following countries. Using predefinied lists of colors
//mexico
void mexicanFlag(){
delay(100);
uint32_t flag[] = {r,w,g,k};
flagColors(flag);
}
//syria
void syrianFlag(){
delay(100);
uint32_t flagA[] = {r,w,g,w};
uint32_t flagB[] = {g,w,k,k};
flagColors(flagA);
flagColors(flagB);
}
//russia
void russianFlag(){
delay(100);
uint32_t flag[] = {w,b,r,k};
flagColors(flag);
}
//israel
void israeliFlag(){
delay(100);
uint32_t flag[] = {b,w,b,k};
flagColors(flag);
}
//venezuela
void venezuelanFlag(){
delay(100);
uint32_t flag[] = {y,b,r,k};
flagColors(flag);
}
//china
void chineseFlag(){
delay(100);
uint32_t flag[] = {r,r,y,r};
flagColors(flag);
}
//Shows a rainbow
void rainbow(){
uint32_t rainbow[] = {w,r,y,g,c,b,m,k};
for(int c=0; c<8; c++) {
for(uint16_t p=0; p< strip.numPixels(); p++) {
//change the color
strip.setPixelColor(p, rainbow[c] );
//show the color
strip.show();
delay( lightSpeed );
}
}
}
//Flashes neopixel leaving all the lights off
void turnoff(){
//run through flag colors with all colors set to off
uint32_t onoff[] = {k,k,k,k};
flagColors(onoff);
}
//makes every neopixel breath once
void pulse(){
//ascending from 0 to 225
for (int i=0; i < 225 ; i++) {
//cycle through every pixel
for(int j=0; j<strip.numPixels(); j++) {
//ascending through shades of white
strip.setPixelColor(j, strip.Color(i,i,i));
}
//show the change
strip.show();
//wait a bit
delay(10);
}
//descending from 225 to 0
for (int i = 225; i > 0; i--) {
//cycle through every pixel
for(int j=0; j<strip.numPixels(); j++) {
//descending through shades of white
strip.setPixelColor(j, strip.Color(i,i,i));
}
//show the change
strip.show();
//wait a bit
delay(10);
}
}
//Takes a list of up to four colors and shows them on the neopixels
void flagColors(uint32_t colors[]){
for(int c=0; c< sizeof(colors); c++) {
for(uint16_t p=0; p< strip.numPixels(); p++) {
//change the color
strip.setPixelColor(p, colors[c] );
//show the color
strip.show();
delay( lightSpeed );
}
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .