Pārlūkot izejas kodu

Add FastLED example

main_ledos
PaulStoffregen pirms 7 gadiem
vecāks
revīzija
3ad147de8b
1 mainītis faili ar 58 papildinājumiem un 0 dzēšanām
  1. +58
    -0
      examples/FastLED_Cylon/FastLED_Cylon.ino

+ 58
- 0
examples/FastLED_Cylon/FastLED_Cylon.ino Parādīt failu

@@ -0,0 +1,58 @@
// FastLED Cylon Example, using Non-Blocking WS2812Serial

#include <WS2812Serial.h>
#define USE_WS2812SERIAL
#include <FastLED.h>

// How many leds in your strip?
#define NUM_LEDS 64

// Usable pins:
// Teensy LC: 1, 4, 5, 24
// Teensy 3.2: 1, 5, 8, 10, 20, 31
// Teensy 3.5: 1, 5, 8, 10, 20, 26, 32, 33, 48
// Teensy 3.6: 1, 5, 8, 10, 20, 26, 32, 33
#define DATA_PIN 1

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
Serial.begin(57600);
Serial.println("resetting");
LEDS.addLeds<WS2812SERIAL,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(84);
}

void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }

void loop() {
static uint8_t hue = 0;
Serial.print("x");
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(20);
}
Serial.print("x");

// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(20);
}
}

Notiek ielāde…
Atcelt
Saglabāt