const int potPin = 34; // Pin for potentiometer
const int ldrPin = 32; // Pin for LDR
const int ledPin = 25; // Pin for LED
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read potentiometer value (simulate soil moisture)
int moistureValue = analogRead(potPin);
// Read LDR value (simulate light level)
int lightValue = analogRead(ldrPin);
// Map the moisture value to LED brightness (0 to 255)
int brightness = map(moistureValue, 0, 4095, 0, 255);
analogWrite(ldrPin, brightness);
// Print values to Serial Monitor
Serial.print("Moisture: ");
Serial.print(moistureValue);
Serial.print(" - Light: ");
Serial.print(lightValue);
Serial.print(" - LED Brightness: ");
Serial.println(brightness);
delay(1000); // Delay for readability
}