Verusche mich gerade an etwas Programmcode um eine, bzw. mehrere WS2812 LEDs einer Stripe blitzen zu lassen. Das will mir nicht gelingen. Ich möchte so einen US-Police-Strobo-Effekterzeugen. Also abwechselnd zwei blaue und zwei rote LEDs mehrfach aufblitzen lassen.
Ist dafür das Protokoll nicht geeignet? Oder der Arduino mit der Neopixel-Lib zu langsam?
WS2812 "blitzen" lassen?
-
-
Klar geht das. Poste mal deinen Code und sag wo du hängst.
-
Uuuh, hab den Fehler scheinbar gefunden. Ich hab die Zeit zwischen EIN und AUS eines LED-Paares viel zu kurz eingestellt. Da war nur ein delay(2) drin und dann sieht es so aus als würde die LED langsam vor sich hin blinken. Mit einem delay(20) oder delay(30) kommt der Effekt schon
Hier trotzdem mein "Code" (übler fieser kleiner Hack):
C
Alles anzeigen// NeoPixel Ring simple sketch (c) 2013 Shae Erisson // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif // Which pin on the Arduino is connected to the NeoPixels? // On a Trinket or Gemma we suggest changing this to 1 #define PIN 4 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 4 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup() { #if defined (__AVR_ATtiny85__) // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif pixels.begin(); // This initializes the NeoPixel library. } void leds_off() { for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, pixels.Color(0, 0, 0)); } pixels.show(); } #define INTER_FLASH_DELAY 30 #define INTER_FLASH_COUNT 10 void red_flash() { for (int c = 0; c < INTER_FLASH_COUNT; c++) { pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.setPixelColor(1, pixels.Color(255, 0, 0)); pixels.show(); delay(INTER_FLASH_DELAY); pixels.setPixelColor(0, pixels.Color(0, 0, 0)); pixels.setPixelColor(1, pixels.Color(0, 0, 0)); pixels.show(); delay(INTER_FLASH_DELAY); } } void blue_flash() { for (int c = 0; c < INTER_FLASH_COUNT; c++) { pixels.setPixelColor(2, pixels.Color(0, 0, 255)); pixels.setPixelColor(3, pixels.Color(0, 0, 255)); pixels.show(); delay(INTER_FLASH_DELAY); pixels.setPixelColor(2, pixels.Color(0, 0, 0)); pixels.setPixelColor(3, pixels.Color(0, 0, 0)); pixels.show(); delay(INTER_FLASH_DELAY); } } void loop() { int i; leds_off(); delay(1000); while(1) { red_flash(); blue_flash(); } }
-
Sieht gut aus, so hätte ich es auch gelöst.
delay(2) sind 2 Millisekunden, da bekommst nicht viel mit davon