Knight_rider_effect.docx

(10 KB) Pobierz

#include <Adafruit_NeoPixel.h>

int PIN = 2;

int count = 0;

int timer = 18;

 

Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800); //defines the strips properties

 

void setColor(int Pixel, int R2, int G2, int B2) {

  uint32_t color = strip.Color(R2, G2, B2); // make a color

  strip.setPixelColor(Pixel, color); //set a single pixel color

  strip.show(); //update the colors

}

void setup() {

  strip.begin(); // initialize the WS2812b strip

  strip.show(); // just make sure everything is off

}

 

void loop() {

  for (count = 0; count < 7; count++) { setColor(count, 255, 0, 0); delay(timer); setColor(count + 1, 255, 0, 0); delay(timer); setColor(count, 0, 0, 0); delay(timer * 2); } for (count = 7; count > 0; count--) {

    setColor(count, 255, 0, 0);

    delay(timer);

    setColor(count - 1, 255, 0, 0);

    delay(timer);

    setColor(count, 0, 0, 0);

    delay(timer * 2);

  }

}

Zgłoś jeśli naruszono regulamin