When the pot reads 0 I want the delay to be 0 and when it reads 1023 I want it to be 3 minutes and for it to scale the values between 0 and 1023 linearly from 0 to 3 minutes. So 341 = 1 minute 682 = 2. This is the code Im using now. I have 30000 plugged into the map function and that works, but when I tried 60000, it stayed on past 1 minute and didnt shut off.
int sensorPin = A5; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
int val = analogRead(5);
val = map(val, 0, 1023, 0, 30000);
// read the value from the sensor:
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(val);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(val);
}