// ESP32 Pot to LED PWM / Potansiyometre ile LED parlaklik
// Pin tanimlari / Pin definitions
const int POT_PIN = 34; // ADC1_CH6, input-only / Classic DevKit V1 safe
const int LED_PIN = 5; // PWM cikis + 220R / PWM out via 220R resistor
void setup() {
Serial.begin(115200);
// 12-bit ADC sabitle / Force 12-bit ADC
analogReadResolution(12);
pinMode(LED_PIN, OUTPUT);
Serial.println("Potansiyometre ile LED parlaklik kontrolu basladi.");
}
void loop() {
int rawValue = analogRead(POT_PIN);
// 0-4095 -> 0-255 / Map ADC to PWM
int brightness = map(rawValue, 0, 4095, 0, 255);
analogWrite(LED_PIN, brightness);
Serial.print("ADC: ");
Serial.print(rawValue);
Serial.print(" | PWM: ");
Serial.println(brightness);
delay(50);
}Loading
esp32-devkit-v1
esp32-devkit-v1