Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Christmas tree top decoration
- // https://youtu.be/clKjGI5lEXQ
- #include <Adafruit_NeoPixel.h>
- #define LED_PIN 6
- #define LED_COUNT 24
- Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
- uint16_t villDelay=300;
- void setup() {
- Serial.begin(115200);
- Serial.println("Start ...");
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
- strip.setBrightness(30); // Set BRIGHTNESS to about 1/5 (max = 255)
- }
- void loop() {
- commo();
- colorWipe(strip.Color(255, 0, 0), 50); // Red
- colorWipe(strip.Color( 0, 255, 0), 50); // Green
- colorWipe(strip.Color( 0, 0, 255), 50); // Blue
- theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
- theaterChase(strip.Color(127, 0, 0), 50); // Red, half brightness
- theaterChase(strip.Color( 0, 0, 127), 50); // Blue, half brightness
- commo();
- rainbow(10); // Flowing rainbow cycle along the whole strip
- commo();
- theaterChaseRainbow(100); // Rainbow-enhanced theaterChase variant
- }
- void colorWipe(uint32_t color, int wait) {
- for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
- strip.setPixelColor(i, color); // Set pixel's color (in RAM)
- strip.show(); // Update strip to match
- delay(wait); // Pause for a moment
- }
- }
- void theaterChase(uint32_t color, int wait) {
- for(int a=0; a<10; a++) { // Repeat 10 times...
- for(int b=0; b<3; b++) { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- // 'c' counts up from 'b' to end of strip in steps of 3...
- for(int c=b; c<strip.numPixels(); c += 3) {
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
- }
- }
- void rainbow(int wait) {
- for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
- strip.rainbow(firstPixelHue);
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
- }
- void theaterChaseRainbow(int wait) {
- int firstPixelHue = 0; // First pixel starts at red (hue 0)
- for(int a=0; a<30; a++) { // Repeat 30 times...
- for(int b=0; b<3; b++) { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- for(int c=b; c<strip.numPixels(); c += 3) {
- int hue = firstPixelHue + c * 65536L / strip.numPixels();
- uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
- }
- void commo(){
- strip.clear();
- strip.show();
- villDelay=50;
- for(int i=24; i>16; i--) { // !
- strip.setPixelColor(i, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- strip.setPixelColor(15, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay*10);
- for(int i=0; i<7; i++) { // Kör 2 oldalt le
- strip.setPixelColor(7+i, strip.Color(255, 0, 0));
- strip.setPixelColor(7-i, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- delay(villDelay*10);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(0, 255, 0));
- strip.show();
- delay(villDelay);
- }
- strip.setPixelColor(15, strip.Color(0, 255, 0));
- strip.show();
- delay(villDelay*10);
- for(int i=7; i>0; i--) {
- strip.setPixelColor(6+i, strip.Color(0, 0, 0));
- strip.setPixelColor(7-i, strip.Color(0, 0, 0));
- strip.show();
- delay(villDelay);
- }
- delay(villDelay*10);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- strip.setPixelColor(15, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay*10);
- for(int i=1; i<14; i++) {
- strip.setPixelColor(i, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- delay(villDelay*10);
- for(int i=1; i<14; i++) {
- strip.setPixelColor(i, strip.Color(0, 0, 0));
- strip.show();
- delay(villDelay);
- }
- delay(villDelay*10);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(0, 255, 0));
- strip.show();
- delay(villDelay);
- }
- strip.setPixelColor(15, strip.Color(0, 255, 0));
- strip.show();
- delay(villDelay*10);
- for(int i=1; i<14; i++) {
- strip.setPixelColor(14-i, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- delay(villDelay*10);
- for(int i=1; i<14; i++) {
- strip.setPixelColor(14-i, strip.Color(0, 0, 0));
- strip.show();
- delay(villDelay);
- }
- villDelay=200;
- for(int j=0; j<3; j++) {
- strip.clear();
- strip.show();
- delay(villDelay);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(0, 255, 0));
- }
- strip.setPixelColor(15, strip.Color(0, 255, 0));
- strip.show();
- delay(villDelay);
- strip.clear();
- strip.show();
- delay(villDelay);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(0, 0, 255));
- }
- strip.setPixelColor(15, strip.Color(0, 0, 255));
- strip.show();
- delay(villDelay);
- strip.clear();
- strip.show();
- delay(villDelay);
- for(int i=24; i>16; i--) {
- strip.setPixelColor(i, strip.Color(255, 0, 0));
- }
- strip.setPixelColor(15, strip.Color(255, 0, 0));
- strip.show();
- delay(villDelay);
- }
- strip.clear();
- strip.show();
- delay(1000);
- }
- // END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement