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.

62 lines
1.2KB

  1. #include <WS2812Serial.h>
  2. const int numled = 64;
  3. const int pin = 1;
  4. // Usable pins:
  5. // Teensy LC: 1, 4, 5, 24
  6. // Teensy 3.2: 1, 5, 8, 10, 20, 31
  7. // Teensy 3.5: 1, 5, 8, 10, 20, 26, 32, 33, 48
  8. // Teensy 3.6: 1, 5, 8, 10, 20, 26, 32, 33
  9. byte drawingMemory[numled*3];
  10. DMAMEM byte displayMemory[numled*12];
  11. WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);
  12. #define RED 0xFF0000
  13. #define GREEN 0x00FF00
  14. #define BLUE 0x0000FF
  15. #define YELLOW 0xFFFF00
  16. #define PINK 0xFF1088
  17. #define ORANGE 0xE05800
  18. #define WHITE 0xFFFFFF
  19. // Less intense...
  20. /*
  21. #define RED 0x160000
  22. #define GREEN 0x001600
  23. #define BLUE 0x000016
  24. #define YELLOW 0x101400
  25. #define PINK 0x120009
  26. #define ORANGE 0x100400
  27. #define WHITE 0x101010
  28. */
  29. void setup() {
  30. leds.begin();
  31. }
  32. void loop() {
  33. // change all the LEDs in 1.5 seconds
  34. int microsec = 1500000 / leds.numPixels();
  35. colorWipe(RED, microsec);
  36. colorWipe(GREEN, microsec);
  37. colorWipe(BLUE, microsec);
  38. colorWipe(YELLOW, microsec);
  39. colorWipe(PINK, microsec);
  40. colorWipe(ORANGE, microsec);
  41. colorWipe(WHITE, microsec);
  42. }
  43. void colorWipe(int color, int wait) {
  44. for (int i=0; i < leds.numPixels(); i++) {
  45. leds.setPixel(i, color);
  46. leds.show();
  47. delayMicroseconds(wait);
  48. }
  49. }