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.

BasicTest_RGBW.ino 1.5KB

4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. }