@ArrchI wanted to see if he would insult me too afterwards, If he did, I would've removed my post and leave him with nothing. I can tolerate rude people to an extent, as I do everyday as a tech support technician. But if I try to help them and they are still ungreatful, then they get blocked.

brilliant! wow, i never know this kind of style. in school i never use this kind of style. you compared it in the last value of the variable.very good sir. i will try this one. i will bow my head for you and say thanks. and! what do you mean by the code millis();?

by the way since you are a genius,i have an out of topic question for you. is it possible to multi quote? so that i can reply to all who posted in my topic easily?. thanks genius man.

@ArrchI wanted to see if he would insult me too afterwards, If he did, I would've removed my post and leave him with nothing. I can tolerate rude people to an extent, as I do everyday as a tech support technician. But if I try to help them and they are still ungreatful, then they get blocked.

You're better than I am at it. I have the philosophy that if you insult anyone trying to help, not just me, I'm not helping until they are apologized too, but that wouldn't work too well for tech support I would imagine.

You know the time that the button was pressed (onTime) copied from millis() when it happened.Later there is a check whether the current time, millis(), minus onTime is greater than 3000. If it is, then 3000 milliseconds (3 seconds) have passed and something needs to be done. If not then don't hang around waiting, get on with something else and check the elapsed time again next time round the loop()

Does that help ?

Please do not send me PMs asking for help. Post in the forum then everyone will benefit from seeing the questions and answers.

You know the time that the button was pressed (onTime) copied from millis() when it happened.Later there is a check whether the current time, millis(), minus onTime is greater than 3000. If it is, then 3000 milliseconds (3 seconds) have passed and something needs to be done. If not then don't hang around waiting, get on with something else and check the elapsed time again next time round the loop()

Does that help ?

the millis records the time between the button is pressed and released? right?

The reason it's not working is because analog gets values 0-255 and digital is 0 or 1. So as of right now your code is looking for a value of 255 to trigger. Your pin might not be putting out 255 but something like 168 or something. So you need to set a range to trigger the if statement to be true.

First you need to see what the value is, then set the IF statement to trigger at that value. It's the same in theory, but with a different setup. Instead of digital readings, it's analog.

The reason it's not working is because analog gets values 0-255 and digital is 0 or 1. So as of right now your code is looking for a value of 255 to trigger. Your pin might not be putting out 255 but something like 168 or something. So you need to set a range to trigger the if statement to be true.

First you need to see what the value is, then set the IF statement to trigger at that value. It's the same in theory, but with a different setup. Instead of digital readings, it's analog.

the upper code is working well, with the if statement greater than 1 . i have messured the analog sensor in digital tester as 0 = (no detection) and more than one ohms if detected.. so i did the line <1 ..... working as good. but when i use without delay method. wont work at all.