0% found this document useful (0 votes)
151 views

Pixel LED Code

Pixel LED Code

Uploaded by

navinkpatel11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views

Pixel LED Code

Pixel LED Code

Uploaded by

navinkpatel11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*pixel LED control with Arduino nano.

Serial monitor readings.


created by the SriTu Tech team.
Read the code below and use it for any of your creation
*/
#include <FastLED.h>//include library---library link in my blog
#define LED 50//num of leds
#define DATAPIN 3//define arduino pin
#define chip WS2811 //chip name
#define colorArrange RGB//color
CRGB pixel [LED];//create array
void setup() {
FastLED.addLeds<chip, DATAPIN, colorArrange>(pixel, LED);//initializing pixel led
}

void loop() {
runRed();
runGreen();
runBlue();
Fill();
fade();
}
void runRed() {
for (byte a = 0; a <= 50; a ++ ) {
pixel[a] = CRGB::Red;
pixel[a + 1] = CRGB::Red;
FastLED.show();
delay(50);
pixel[a] = CRGB::Black;
pixel[a + 1] = CRGB::Black;
}
}
void runGreen() {
for (byte x = 0; x <= 50; x ++ ) {
pixel[x] = CRGB::Green;
pixel[x + 1] = CRGB::Green;
FastLED.show();
delay(50);
pixel[x] = CRGB::Black;
pixel[x + 1] = CRGB::Black;
}
}
void runBlue() {
for (byte x = 0; x <= 50; x ++ ) {
pixel[x] = CRGB::Blue;
pixel[x + 1] = CRGB::Blue;
FastLED.show();
delay(50);
pixel[x] = CRGB::Black;
pixel[x + 1] = CRGB::Black;
}
}
void Fill() {
for (byte a = 0; a <= 50; a++) {
pixel[a] = CRGB::Red;
FastLED.show();
delay(30);
}
for (byte b = 0; b <= 50; b++) {
pixel[b] = CRGB::Green;
FastLED.show();
delay(30);
}
for (byte c = 0; c <= 50; c++) {
pixel[c] = CRGB::Blue;
FastLED.show();
delay(30);
}
for (byte d = 0; d <= 50; d++) {
pixel[d] = CRGB::Yellow;
FastLED.show();
delay(30);
}
}
void fade() {
for (int w = 0; w <= 50; w++) {
pixel[w] = CRGB(0, 0, 255);
pixel[w + 1] = CRGB(0, 0, 230);
pixel[w + 2] = CRGB(0, 0, 210);
pixel[w + 3] = CRGB(0, 0, 190);
pixel[w + 4] = CRGB(0, 0, 150);
FastLED.show();
delay(50);
pixel[w] = CRGB(0, 0, 0);
pixel[w + 1] = CRGB(0, 0, 0);
pixel[w + 2] = CRGB(0, 0, 0);
pixel[w + 3] = CRGB(0, 0, 0);
pixel[w + 4] = CRGB(0, 0, 0);
FastLED.show();
}
}

You might also like