Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

68 rindas
1.4KB

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