Jednoduchý příklad jak pomocí jednoto tlačítka nechat obíhat 1 LED po pásku…
/* This example shows how to make an LED pattern with a large * dynamic range using the the extra 5-bit brightness register in * the APA102. * * It sets every LED on the strip to white, with the dimmest * possible white at the input end of the strip and the brightest * possible white at the other end, and a smooth logarithmic * gradient between them. * * The dimmest possible white is achieved by setting the red, * green, and blue color channels to 1, and setting the * brightness register to 1. The brightest possibe white is * achieved by setting the color channels to 255 and setting the * brightness register to 31. */ /* By default, the APA102 library uses pinMode and digitalWrite * to write to the LEDs, which works on all Arduino-compatible * boards but might be slow. If you have a board supported by * the FastGPIO library and want faster LED updates, then install * the FastGPIO library and uncomment the next two lines: */ // #include <FastGPIO.h> // #define APA102_USE_FAST_GPIO #include <APA102.h> // Define which pins to use. const uint8_t dataPin = 11; const uint8_t clockPin = 12; int buttonPin = 10; APA102<dataPin, clockPin> ledStrip; // ledCount = počet LED na pásku const uint16_t ledCount = 30; rgb_color colors[ledCount]; void setup() { pinMode(buttonPin, INPUT_PULLUP); ledStrip.startFrame(); /*OPRAVIT NA for(uint16_t i = 0; i < ledCount; i++) */ for(uint16_t i = 0; i < 30; i++) { // poslat barvu na jednu LED: Červená(0-255), Zelená(0-255), Modrá(0-255), Intenzita svitu (0-31) ledStrip.sendColor(0, 0, 0, 0); } //ukončení posílání ledStrip.endFrame(ledCount); } void loop() { int Red = 255; int Green = 0; int Blue = 0; int Alfa = 31; for(uint16_t i = 0; i < ledCount; i++) { do { delay(10); } while (digitalRead(buttonPin) == HIGH); ledStrip.startFrame(); for(uint16_t j = 0; j < ledCount; j++) { if( i == j){ ledStrip.sendColor(Red, Green, Blue, Alfa); } else{ ledStrip.sendColor(Red, Green, Blue, 0); // Alfa = 0 .. tedy vypnuto } } ledStrip.endFrame(ledCount); //delay(300); } }