// ACTIVITY 3: LED with potentiometer
// Angeline Salas
// Irish Poblete
// Firstly, let's define the pin numbers
int potPin = A0; // Potentiometer connected to analog pin A0
int ledPin = 13; // LED connected to digital pin 13
int potValue = 0; // Variable to store the potentiometer value
void setup() {
// Then, set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the analog value from the potentiometer
potValue = analogRead(potPin);
// We'll map the potentiometer value to a delay time range
int delayTime = map(potValue, 0, 1023, 50, 200); // Potentiometer values range from 0 to 1023, delay time ranges from 50 to 200 milliseconds
// Turn off the LED
digitalWrite(ledPin, LOW);
// Wait for the calculated delay time
delay(delayTime);
// Turn on the LED
digitalWrite(ledPin, HIGH);
// Lastly, we wait for the same delay time
delay(delayTime);
}