how to replace delay() to millis()

Robin2:
The whole purpose of using millis() instead of delay() is to replace blocking code with non-blocking code.

The inherent and actual purpose of the millis() function is known to the veteran; but, not to the OP (a beginner) as I can say from my experience; your experience could be different. Allowing a LED to remain ON for 1-sec time and then looking around within that 1-sec time to see if there is anything to do while checking if the said 1-sec time is over -- a non-blocking concept that can only be visualized by a veteran.

150 senior level pupils were given the following task; unfortunately, none of them could come up with correct solution within 50 minutes of the period and yet, there are students among them who will become teachers of the institute after graduation!

"Create sketch so that the L (built-in LED of UNO) of the following circuit remains ON for 1-sec time as long as the button K1 remains at open condition."
built-inL.png

Edited diagram in response to the reaction of Post#21.
builtInL.png

built-inL.png

builtInL.png

150 senior level pupils were given the following task; unfortunately, none of them could come up with correct solution within 50 minutes of the period

Given that atrocious and non standard diagram I am not surprised

UKHeliBob:
Given that atrocious and non standard diagram I am not surprised

Any suggestion?

GolamMostafa:
Any suggestion?

Yes.

Start your own Thread in which to pursue your questions. Don't hijack some other person's Thread.

...R

Robin2:
Yes.

Start your own Thread in which to pursue your questions. Don't hijack some other person's Thread.

Suggestion has been sought to improve the quality of the diagram (of Post#20)?

GolamMostafa:
Suggestion has been sought to improve the quality of the diagram (of Post#20)?

Indeed. But the diagram should never have been posted in this Thread in the first place - it has nothing useful to say to the OP.

...R

GolamMostafa:
Suggestion has been sought to improve the quality of the diagram (of Post#20)?

Why are you using an incandescent lamp symbol where a LED symbol should be used?

“remains ON for 1-sec time as long as the button K1 remains at open condition.”
‘Turns on’ for 1-second when the switch K1 opens and stays open.

larryd:

  1. Why are you using an incandescent lamp symbol where a LED symbol should be used?

  2. “remains ON for 1-sec time as long as the button K1 remains at open condition.”
    ‘Turns on’ for 1-second when the switch K1 opens and stays open.

  1. From the following 3 symbols of the Library of Visio, I have chosen the first one owing to its resemblance a physical LED.
    lamp.png

  2. Thank you for the nice paraphrase of my sentence. (+)

lamp.png

For the price for Visio, surely you can create a LED symbol.

https://www.google.com/search?biw=1236&bih=568&tbm=isch&sa=1&ei=lQoyXey0M-uv0PEPiKaIgAI&q="visio"+led+symbol&oq="visio"+led+symbol&gs_l=img.12...0.0..19549...0.0..0.0.0.......0......gws-wiz-img.Z1r0CIXbih4&ved=0ahUKEwis05OQzcHjAhXrFzQIHQgTAiAQ4dUDCAY

GolamMostafa:
The OP has not asked for non-blocking codes. Probably, he has wished to get familiar with the usage of millis() function.

UKHeliBob:
At least, not yet

Seems he has now... not in as many words, but needs a button to "immediately" (his word) turn the current led off.

So yeah "well done" to AKRF and GolamMostafa for effectively putting the OP back 3 weeks. He now needs to re-jig the sketch he had to accommodate the immediacy of the button.