Hi, my delay function stopped at once without doing anything, using and Arduino Uno.
I took this code from an youtube tutorial and it worked fine until next day... just starting the arduino and everything runs as normal exept the delay function does not work anymore.
Installed the IDE again, reset the board, tried some other code like timer=0, using microseconds..
Anybody experienced a problem with the board without changing anything?
//set pin numbers
const int ledPin = 2;
const int buttonPin1 = 4;
//variables will change
int buttonState1 = 0;
int timer = 0; //added myself, just a try
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
if (buttonState1 == HIGH) {
digitalWrite(ledPin, HIGH);
Serial.println("LED ON 10 Detik");
delay(100);
}
else {
digitalWrite(ledPin, LOW);
Serial.println("LED OFF -------");
}
}
Thankyou, i might think something happens to the hardware of the board because i did not change anything in between the problem occurred.
I tried a pulldown resistor yes but thats interrupting the fet module that i operate with is, and by the way the circuit switches as it should only without the delay
I see, well i use a light sensor module which is the ‘button’ and a fet module that is mentioned as ‘led’, so when the light module gives a signal the fet has to switch for a specific time (delay), in this case mentioned 100 miliseconds
This is my first project, 'Print the value of buttonState1 after you read the input', it's not clear how to implement this... The serial monitor shows 'led on 10 detik' repeating