Hi i tried to set a time with the potentiometer of blinking the led.
I was successful to 32 sec but 33 and later not.
Here is the code :
/* Analog Read to LED
turns on and off a light emitting diode(LED) connected to digital
pin 13. The amount of time the LED will be on and off depends on
the value obtained by analogRead(). In the easiest case we connect
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 4; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin)*32; // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
Sorry for my bad english I am from Serbia...
Thank you !
(Have a look at Unsigned long type and use 32UL instead of 32 to force unsigned long calculation or cast the result of digitalRead to an unsigned long value)
I was trying to have him understand his mistake and read some doc
Jovica did you read the links I sent? What is the max value of an int? Do you see why this is a pb? And why your code works up until a certain point and not after?