This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int potPin = A0; // Potentiometer connected to analog pin A0 | |
| int ledPin = 10; // LED connected to PWM pin 9 | |
| // Potentiometer range for LED activation (adjust these values to fit your needs) | |
| int potLow = 400; // Lower threshold value of potentiometer reading | |
| int potHigh = 600; // Upper threshold value of potentiometer reading | |
| // Variables to keep track of time and LED state | |
| unsigned long inRangeStartTime = 0; // Stores the time when potentiometer entered the range | |
| bool lightIsOn = false; // Flag to track whether LED is currently on or off |