#include <Adafruit_NeoPixel.h>
#define PIN 8
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 100
void setup() {
Serial.begin(115200);
pixels.begin();
}
int lastValue = 0;
void loop() {
int value = analogRead(4) >> 4;
if (lastValue != value) {
Serial.println(value);
lastValue = value;
}
pixels.clear();
for(int i=0; i<NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(value, 0, 0));
pixels.show();
delay(DELAYVAL);
}
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1