unsigned long second;
void setup() {
ledcSetup(0, 1000, 8);
ledcAttachPin(2, 0);
pinMode(4, INPUT);
Serial.begin(9600);
Serial.println("Hello, ESP32!");
}
void loop() {
int A = analogRead(4);
int B = map(A, 0, 4095, 0, 255);
ledcWrite(0, B);
dacWrite(25, B);
if(millis() > second)
{
second += 1000;
int C = map(B, 0, 255, 0, 100);
Serial.print("Brightness: ");
Serial.print(C);
Serial.println("%");
}
}