You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 7 година
пре 5 година
пре 7 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // FastLED Cylon Example, using Non-Blocking WS2812Serial
  2. #include <WS2812Serial.h>
  3. #define USE_WS2812SERIAL
  4. #include <FastLED.h>
  5. // How many leds in your strip?
  6. #define NUM_LEDS 64
  7. // Usable pins:
  8. // Teensy LC: 1, 4, 5, 24
  9. // Teensy 3.2: 1, 5, 8, 10, 31 (overclock to 120 MHz for pin 8)
  10. // Teensy 3.5: 1, 5, 8, 10, 26, 32, 33, 48
  11. // Teensy 3.6: 1, 5, 8, 10, 26, 32, 33
  12. // Teensy 4.0: 1, 8, 14, 17, 20, 24, 29, 39
  13. // Teensy 4.1: 1, 8, 14, 17, 20, 24, 29, 35, 47, 53
  14. #define DATA_PIN 1
  15. // Define the array of leds
  16. CRGB leds[NUM_LEDS];
  17. void setup() {
  18. Serial.begin(57600);
  19. Serial.println("resetting");
  20. LEDS.addLeds<WS2812SERIAL,DATA_PIN,RGB>(leds,NUM_LEDS);
  21. LEDS.setBrightness(84);
  22. }
  23. void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
  24. void loop() {
  25. static uint8_t hue = 0;
  26. Serial.print("x");
  27. // First slide the led in one direction
  28. for(int i = 0; i < NUM_LEDS; i++) {
  29. // Set the i'th led to red
  30. leds[i] = CHSV(hue++, 255, 255);
  31. // Show the leds
  32. FastLED.show();
  33. // now that we've shown the leds, reset the i'th led to black
  34. // leds[i] = CRGB::Black;
  35. fadeall();
  36. // Wait a little bit before we loop around and do it again
  37. delay(20);
  38. }
  39. Serial.print("x");
  40. // Now go in the other direction.
  41. for(int i = (NUM_LEDS)-1; i >= 0; i--) {
  42. // Set the i'th led to red
  43. leds[i] = CHSV(hue++, 255, 255);
  44. // Show the leds
  45. FastLED.show();
  46. // now that we've shown the leds, reset the i'th led to black
  47. // leds[i] = CRGB::Black;
  48. fadeall();
  49. // Wait a little bit before we loop around and do it again
  50. delay(20);
  51. }
  52. }