Skip to content

Instantly share code, notes, and snippets.

View MichelleRMIT's full-sized avatar

Michelle@RMIT MichelleRMIT

View GitHub Profile
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