This is an old revision of the document!
Disclaimer: nu sunt responsabil pentru daunele provocate de glumele mele
Functionalitate:
Schema bloc:
Lista de piese:
Schema electrica:
Test initial:
Daca aveti ceva death wish, trebuie descarcat PlatformIO, inclusa biblioteca AdaFruit_DotStar si adaugat gunoiul ala de demo. Oh si sa aveti o ragalie de ventilator overengineered ca al meu.
#include <Adafruit_DotStar.h> #include <Arduino.h> // Because conditional #includes don't work w/Arduino sketches... #include <SPI.h> // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET // #include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET #define NUMPIXELS 72 // Number of LEDs in strip // Here's how to control the LEDs from any two pins: #define TRIGGERPIN 9 #define DATAPIN 10 #define CLOCKPIN 11 Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG); int head = 0, tail = -20; // Index of first 'on' and 'off' pixels uint32_t movingColor = 0x00FFFF, color = 0xFF00FF; // purple and cyan void setup() { #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L) clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket #endif Serial.begin(115200); // For debugging Serial.println("DotStar Simple"); strip.begin(); // Initialize pins for output strip.show(); // Turn all LEDs off ASAP for (int i = 0; i < NUMPIXELS; i++) { // Loop thru all pixels in strip... strip.setPixelColor(i, color); // Set pixel's color (in RAM) } strip.setBrightness(255); // Max brightness strip.show(); // Update strip to match } bool direction = true; int trigger = HIGH; int lastTrigger = HIGH; void loop() { lastTrigger = digitalRead(TRIGGERPIN); strip.setPixelColor(head, movingColor); strip.setPixelColor(tail, color); // move a "snake" of pixels along the strip up to the middle if (trigger == HIGH && lastTrigger == LOW) { if (++head >= NUMPIXELS) { head = 0; } if (++tail >= NUMPIXELS) { tail = 0; } strip.setPixelColor(head, movingColor); strip.setPixelColor(tail, color); { if (direction) { // going to the edge if (tail >= 0) { strip.setPixelColor(tail, color); } strip.setPixelColor(head, movingColor); if (++head > NUMPIXELS / 2 - 1) { direction = false; --head; } else { ++tail; } } else { // going to the middle strip.setPixelColor(head, color); strip.setPixelColor(tail, movingColor); if (--tail < 0) { direction = true; ++tail; } else { --head; } } } trigger = lastTrigger; // update trigger strip.show(); // Update strip with new contents } }===== Rezultate Obţinute ===== Nu se vede chiar bine in poza dar se observa efectul POV (da, poza e facuta in garaj):