Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

58 linhas
1.5KB

  1. /* WS2812Serial BasicTest_RGBW Example - Works with SK6812 RGBW LEDs
  2. Test LEDs by turning then 7 different colors.
  3. This example code is in the public domain. */
  4. #include <WS2812Serial.h>
  5. const int numled = 20;
  6. const int pin = 1;
  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. byte drawingMemory[numled*4]; // 4 bytes per LED for RGBW
  15. DMAMEM byte displayMemory[numled*16]; // 16 bytes per LED for RGBW
  16. WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRBW);
  17. #define RED 0x00FF0000
  18. #define GREEN 0x0000FF00
  19. #define BLUE 0x000000FF
  20. #define YELLOW 0x00FFD000
  21. #define PINK 0x44F00080
  22. #define ORANGE 0x00FF4200
  23. #define WHITE 0xAA000000
  24. void setup() {
  25. leds.begin();
  26. leds.setBrightness(200); // 0=off, 255=brightest
  27. }
  28. void loop() {
  29. // change all the LEDs in 1.5 seconds
  30. int microsec = 1500000 / leds.numPixels();
  31. colorWipe(RED, microsec);
  32. colorWipe(GREEN, microsec);
  33. colorWipe(BLUE, microsec);
  34. colorWipe(YELLOW, microsec);
  35. colorWipe(PINK, microsec);
  36. colorWipe(ORANGE, microsec);
  37. colorWipe(WHITE, microsec);
  38. }
  39. void colorWipe(int color, int wait_us) {
  40. for (int i=0; i < leds.numPixels(); i++) {
  41. leds.setPixel(i, color);
  42. leds.show();
  43. delayMicroseconds(wait_us);
  44. }
  45. }