PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

54 lines
1.4KB

  1. #include <FastLED.h>
  2. // How many leds in your strip?
  3. #define NUM_LEDS 64
  4. // For led chips like Neopixels, which have a data line, ground, and power, you just
  5. // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
  6. // ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
  7. #define DATA_PIN 7
  8. #define CLOCK_PIN 13
  9. // Define the array of leds
  10. CRGB leds[NUM_LEDS];
  11. void setup() {
  12. Serial.begin(57600);
  13. Serial.println("resetting");
  14. LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
  15. LEDS.setBrightness(84);
  16. }
  17. void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
  18. void loop() {
  19. static uint8_t hue = 0;
  20. Serial.print("x");
  21. // First slide the led in one direction
  22. for(int i = 0; i < NUM_LEDS; i++) {
  23. // Set the i'th led to red
  24. leds[i] = CHSV(hue++, 255, 255);
  25. // Show the leds
  26. FastLED.show();
  27. // now that we've shown the leds, reset the i'th led to black
  28. // leds[i] = CRGB::Black;
  29. fadeall();
  30. // Wait a little bit before we loop around and do it again
  31. delay(10);
  32. }
  33. Serial.print("x");
  34. // Now go in the other direction.
  35. for(int i = (NUM_LEDS)-1; i >= 0; i--) {
  36. // Set the i'th led to red
  37. leds[i] = CHSV(hue++, 255, 255);
  38. // Show the leds
  39. FastLED.show();
  40. // now that we've shown the leds, reset the i'th led to black
  41. // leds[i] = CRGB::Black;
  42. fadeall();
  43. // Wait a little bit before we loop around and do it again
  44. delay(10);
  45. }
  46. }