const int PM = 34; //GPIO 34 (Analog pin)
const int LED = 23; //GPIO 23 (Digital pin for led)
const int BUZZER = 23;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); // Start serial communication
pinMode(LED, OUTPUT); //set LED pin as output
pinMode(BUZZER, OUTPUT);
}void loop() {
// Read the value from the potentiometer
int PMValue = analogRead(PM);
// print the value to the serial Monitor
Serial.print("Potentiometer Value: ");
Serial.print("Potentiometer Value: ");
Serial.println(PMValue);
// Map the potentiometer value to LED Broightness (0-255)
int Lbright = map(PMValue, 0, 4095, 0, 255);
// set the LED brightness
analogWrite(LED, Lbright);
delay(500);
if (PMValue > 2000) {
digitalWrite(BUZZER, HIGH); // turn the buzzer ON
} else {
digitalWrite(BUZZER, LOW); // turn the buzzer OFF
}
// Add a small delay for rea
}