PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

BasicTest_RGBW.ino 1.4KB

před 4 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. byte drawingMemory[numled*4]; // 4 bytes per LED for RGBW
  14. DMAMEM byte displayMemory[numled*16]; // 16 bytes per LED for RGBW
  15. WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRBW);
  16. #define RED 0x00FF0000
  17. #define GREEN 0x0000FF00
  18. #define BLUE 0x000000FF
  19. #define YELLOW 0x00FFD000
  20. #define PINK 0x44F00080
  21. #define ORANGE 0x00FF4200
  22. #define WHITE 0xAA000000
  23. void setup() {
  24. leds.begin();
  25. leds.setBrightness(200); // 0=off, 255=brightest
  26. }
  27. void loop() {
  28. // change all the LEDs in 1.5 seconds
  29. int microsec = 1500000 / leds.numPixels();
  30. colorWipe(RED, microsec);
  31. colorWipe(GREEN, microsec);
  32. colorWipe(BLUE, microsec);
  33. colorWipe(YELLOW, microsec);
  34. colorWipe(PINK, microsec);
  35. colorWipe(ORANGE, microsec);
  36. colorWipe(WHITE, microsec);
  37. }
  38. void colorWipe(int color, int wait_us) {
  39. for (int i=0; i < leds.numPixels(); i++) {
  40. leds.setPixel(i, color);
  41. leds.show();
  42. delayMicroseconds(wait_us);
  43. }
  44. }