Advertisement
NoNnYhA55

Always Random Color LED Ring ESP32

Oct 23rd, 2023
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.55 KB | Software | 0 0
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3.  #include <avr/power.h>
  4. #endif
  5. #define PIN 21
  6. #define NUMPIXELS 24
  7. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  8.  
  9. void setup() {
  10. #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  11.   clock_prescale_set(clock_div_1);
  12. #endif
  13.  
  14.   pixels.begin();
  15. }
  16.  
  17. void loop() {
  18.   int r = random(0, 256);
  19.   int g = random(0, 256);
  20.   int b = random(0, 256);
  21.  
  22.   for(int i = 0; i < NUMPIXELS; i++) {
  23.     pixels.setPixelColor(i, pixels.Color(r, g, b));
  24.     pixels.show();
  25.     delay(50);
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement