Arduino – Neopixel + Variable Resistor – Brightness control
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include <Adafruit_NeoPixel.h> #define PIN 2 Adafruit_NeoPixel strip=Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800); int varRes=A1; int colors=0; void setup() { strip.begin(); strip.show(); } void loop() { colors=map(analogRead(varRes), 0, 1023, 0, 255); for (int i=0;i<strip.numPixels();i++) { strip.setPixelColor(i, strip.Color(colors, colors, colors)); } strip.show(); } |