# include "FastLED.h"
# define NUM_LEDS 60
# define DATA_PIN 3
# define LED_TYPE WS2812
# define COLOR_ORDER GRB
uint8_t max_bright = 100 ;
CRGB leds[ NUM_LEDS] ;
void led_rainbow_loop ( void ) {
FastLED. clear ( ) ;
FastLED. show ( ) ;
delay ( 500 ) ;
fill_solid ( leds, 60 , CRGB:: Red) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Orange) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Yellow) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Green) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Cyan) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Blue) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
fill_solid ( leds, 60 , CRGB:: Purple) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
}
void led_rainbow_flowing ( void )
{
FastLED. clear ( ) ;
FastLED. show ( ) ;
delay ( 500 ) ;
int i = 0 , loop_count = 0 ;
if ( NUM_LEDS% 7 == 0 )
{
loop_count = NUM_LEDS/ 7 ;
}
else
{
loop_count = NUM_LEDS/ 7 + 1 ;
}
for ( i= 0 ; i< loop_count; i++ )
{
leds[ i* 7 ] = CRGB:: Red;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 1 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 1 ] = CRGB:: Orange;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 2 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 2 ] = CRGB:: Yellow;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 3 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 3 ] = CRGB:: Green;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 4 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 4 ] = CRGB:: Cyan;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 5 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 5 ] = CRGB:: Blue;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 6 >= NUM_LEDS)
{
break ;
}
leds[ i* 7 + 6 ] = CRGB:: Purple;
FastLED. show ( ) ;
delay ( 200 ) ;
if ( i* 7 + 7 >= NUM_LEDS)
{
break ;
}
}
}
void led_rainbow_static ( void ) {
FastLED. clear ( ) ;
FastLED. show ( ) ;
delay ( 500 ) ;
fill_rainbow ( leds, 60 , 0 , 15 ) ;
FastLED. show ( ) ;
delay ( 1000 ) ;
}
void setup ( ) {
LEDS. addLeds < LED_TYPE, DATA_PIN, COLOR_ORDER> ( leds, NUM_LEDS) ;
FastLED. setBrightness ( max_bright) ;
}
void loop ( ) {
while ( 1 ) {
led_rainbow_flowing ( ) ;
led_rainbow_static ( ) ;
led_rainbow_loop ( ) ;
}
}
# include <Adafruit_NeoPixel.h>
# include <ctime>
# define PIN D1
# define NUMPIXELS 29
Adafruit_NeoPixel pixels = Adafruit_NeoPixel ( NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800) ;
int delayval2 = 40 ;
void setup ( ) {
srand ( ( unsigned ) time ( NULL ) ) ;
pixels. setBrightness ( 25 ) ;
pixels. begin ( ) ;
}
void loop ( ) {
uint32_t light2c = pixels. Color ( rand ( ) % 255 , rand ( ) % 255 , rand ( ) % 255 ) ;
int light2bright = 10 ;
for ( int i= 0 ; i< NUMPIXELS; i++ ) {
pixels. setPixelColor ( i, light2c) ;
pixels. show ( ) ;
}
while ( true ) {
light2bright+= 10 ;
pixels. setBrightness ( light2bright) ;
pixels. show ( ) ;
delay ( delayval2) ;
if ( light2bright>= 200 )
break ;
}
while ( true ) {
light2bright-= 10 ;
pixels. setBrightness ( light2bright) ;
pixels. show ( ) ;
delay ( delayval2) ;
if ( light2bright<= 10 )
break ;
}
}