// HAZI TECH
// Programmed by Hasitha Jayasundara
// Visit my YouTube Channel - http://www.youtube.com/c/HAZITECH?sub_confirmation=1
#include "Arduino.h"
#include <FastLED.h>
#define DATA_PIN 5
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 50 //Total no of LEDs (Maximum 500 LEDs - Use multiplications of 5 : Eg.5,10,15,....50,55,60,....500)
CRGB leds[NUM_LEDS];
void setup()
{
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(255);
}
void loop()
{
Flag_Flow();
Flag_Flow();
Fade_Full();
Flag();
Flag();
Flag();
Full_Fill();
Flag_Fill_Segments_1();
Flag_Fill_Segments_2();
Flag_Fill_Segments_3();
Flag_Fill();
Flag_Fill();
Flag_Runner_1();
Flag_Runner_1();
Flag_Runner_1();
Flag_Runner_2();
Flag_Runner_2();
Flag_Runner_3();
Flag_Runner_3();
Flag_Runner_3();
Flag_Runner_3();
Flag_Runner_3();
}
void Flag_Flow()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
FastLED.show();
delay (10);
}
delay (500);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
FastLED.show();
delay (10);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Orange;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::White;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Red;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Yellow;
FastLED.show();
delay (10);
}
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Blue;
FastLED.show();
delay (10);
}
delay (500);
for (int i = (NUM_LEDS-1); i >= 0; i--)
{
leds[i] = CRGB::Black;
FastLED.show();
delay (10);
}
delay (500);
}
void Fade_Full()
{
for (int j = 0; j <= 255; j++)
{
fill_solid(leds, NUM_LEDS, CRGB::Blue);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
fill_solid(leds, NUM_LEDS, CRGB::Blue);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 0; j <= 255; j++)
{
fill_solid(leds, NUM_LEDS, CRGB::Yellow);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
fill_solid(leds, NUM_LEDS, CRGB::Yellow);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 0; j <= 255; j++)
{
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 0; j <= 255; j++)
{
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 0; j <= 255; j++)
{
fill_solid(leds, NUM_LEDS, CRGB::Orange);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
fill_solid(leds, NUM_LEDS, CRGB::Orange);
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
FastLED.setBrightness(255);
}
void Flag()
{
for (int j = 0; j <= 255; j++)
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
}
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
for (int j = 255; j >= 0; j--)
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
}
FastLED.setBrightness(j);
FastLED.show();
delay (3);
}
FastLED.setBrightness(255);
}
void Full_Fill()
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Blue;
FastLED.show();
delay (10);
}
delay (500);
for (int i = NUM_LEDS-1; i >= 0; i--)
{
leds[i] = CRGB::Yellow;
FastLED.show();
delay (10);
}
delay (500);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Red;
FastLED.show();
delay (10);
}
delay (500);
for (int i = NUM_LEDS-1; i >= 0; i--)
{
leds[i] = CRGB::White;
FastLED.show();
delay (10);
}
delay (500);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Orange;
FastLED.show();
delay (10);
}
delay (500);
for (int i = NUM_LEDS-1; i >= 0; i--)
{
leds[i] = CRGB::White;
FastLED.show();
delay (10);
}
delay (500);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Red;
FastLED.show();
delay (10);
}
delay (500);
for (int i = NUM_LEDS-1; i >= 0; i--)
{
leds[i] = CRGB::Yellow;
FastLED.show();
delay (10);
}
delay (500);
}
void Flag_Fill_Segments_1()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
FastLED.show();
delay (50);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(3*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Orange;
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::White;
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Red;
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Yellow;
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Blue;
FastLED.show();
delay (50);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
}
void Flag_Fill_Segments_2()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
FastLED.show();
delay (50);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
}
void Flag_Fill_Segments_3()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Orange;
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::White;
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Red;
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Yellow;
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Blue;
FastLED.show();
delay (50);
}
delay (500);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(3*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
}
void Flag_Fill()
{
for (int i = 0; i < 5*(NUM_LEDS/5); i++)
{
leds[i] = CRGB::Orange;
FastLED.show();
delay (20);
}
for (int i = 0; i < 4*(NUM_LEDS/5); i++)
{
leds[i] = CRGB::White;
FastLED.show();
delay (20);
}
for (int i = 0; i < 3*(NUM_LEDS/5); i++)
{
leds[i] = CRGB::Red;
FastLED.show();
delay (20);
}
for (int i = 0; i < 2*(NUM_LEDS/5); i++)
{
leds[i] = CRGB::Yellow;
FastLED.show();
delay (20);
}
for (int i = 0; i < 1*(NUM_LEDS/5); i++)
{
leds[i] = CRGB::Blue;
FastLED.show();
delay (20);
}
delay (1000);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(1*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(2*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(3*(NUM_LEDS/5))] = CRGB::Black;
leds[i+(4*(NUM_LEDS/5))] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
for (int i = NUM_LEDS; i >= 0*(NUM_LEDS/5); i--)
{
leds[i] = CRGB::Blue;
FastLED.show();
delay (20);
}
for (int i = NUM_LEDS; i >= 1*(NUM_LEDS/5); i--)
{
leds[i] = CRGB::Yellow;
FastLED.show();
delay (20);
}
for (int i = NUM_LEDS; i >= 2*(NUM_LEDS/5); i--)
{
leds[i] = CRGB::Red;
FastLED.show();
delay (20);
}
for (int i = NUM_LEDS; i >= 3*(NUM_LEDS/5); i--)
{
leds[i] = CRGB::White;
FastLED.show();
delay (20);
}
for (int i = NUM_LEDS; i >= 4*(NUM_LEDS/5); i--)
{
leds[i] = CRGB::Orange;
FastLED.show();
delay (20);
}
delay (1000);
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[(5*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(4*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(3*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(2*(NUM_LEDS/5)-1)-i] = CRGB::Black;
leds[(1*(NUM_LEDS/5)-1)-i] = CRGB::Black;
FastLED.show();
delay (50);
}
delay (500);
}
void Flag_Runner_1 ()
{
Blue ();
delay (200);
FastLED.clear();
Yellow ();
delay (200);
FastLED.clear();
Red ();
delay (200);
FastLED.clear();
White ();
delay (200);
FastLED.clear();
Orange ();
delay (200);
FastLED.clear();
White ();
delay (200);
FastLED.clear();
Red ();
delay (200);
FastLED.clear();
Yellow ();
delay (200);
FastLED.clear();
}
void Flag_Runner_2 ()
{
Blue ();
delay (200);
Yellow ();
delay (200);
Red ();
delay (200);
White ();
delay (200);
Orange ();
delay (200);
Orange_OFF ();
delay (200);
White_OFF ();
delay (200);
Red_OFF ();
delay (200);
Yellow_OFF ();
delay (200);
Blue_OFF ();
delay (200);
Orange ();
delay (200);
White ();
delay (200);
Red ();
delay (200);
Yellow ();
delay (200);
Blue ();
delay (200);
Blue_OFF ();
delay (200);
Yellow_OFF ();
delay (200);
Red_OFF ();
delay (200);
White_OFF ();
delay (200);
Orange_OFF ();
delay (200);
}
void Flag_Runner_3 ()
{
Yellow_OFF ();
White_OFF ();
Blue ();
Red ();
Orange ();
delay (200);
Blue_OFF ();
Red_OFF ();
Orange_OFF ();
Yellow ();
White ();
delay (200);
}
void Blue ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Blue;
}
FastLED.show();
}
void Blue_OFF ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(0*(NUM_LEDS/5))] = CRGB::Black;
}
FastLED.show();
}
void Yellow ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(1*(NUM_LEDS/5))] = CRGB::Yellow;
}
FastLED.show();
}
void Yellow_OFF ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(1*(NUM_LEDS/5))] = CRGB::Black;
}
FastLED.show();
}
void Red ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(2*(NUM_LEDS/5))] = CRGB::Red;
}
FastLED.show();
}
void Red_OFF ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(2*(NUM_LEDS/5))] = CRGB::Black;
}
FastLED.show();
}
void White ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(3*(NUM_LEDS/5))] = CRGB::White;
}
FastLED.show();
}
void White_OFF ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(3*(NUM_LEDS/5))] = CRGB::Black;
}
FastLED.show();
}
void Orange ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(4*(NUM_LEDS/5))] = CRGB::Orange;
}
FastLED.show();
}
void Orange_OFF ()
{
for (int i = 0; i < (NUM_LEDS/5); i++)
{
leds[i+(4*(NUM_LEDS/5))] = CRGB::Black;
}
FastLED.show();
}