I tried to understand your explanations but sorry I couldn't understandGood. Now you need to find a delay() function that can supply our time periods.
Usually, delay(1000); will wait for 1 second (1000 ms).
Having a function such as delay() makes it much easier to get accurate timing than
trying to use for loops, because the for loop can vary with processor speed, load, etc.
For step 1, you want to turn the LED1 on, then off, every 1/4 second, for 10 seconds.
for total_time = 1 to 10 # total time for step 1 in seconds
for one_second = 1 to 4 # number of times required to blink for one second
turn off LED1; #how you do this is hardware dependent
delay(125); #wait 1/8 second
// each time thru this loop will take 250 ms or 1/4 second.
// so you need to do it 4 times to add up to 1 second
end for one_second
end for total_time
Steps 2 and 3 would work in the same way - but no good programmer would simply write three copies of his code, and change the numbers. Ask why not.
I understand meaning of above two line. you are making LED on for 125msturn on LED1; #how you do this is hardware dependent
delay(125); #wait 1/8 second (125 ms)
same, you are making LED off for 125 secondsturn off LED1; #how you do this is hardware dependent
delay(125); #wait 1/8 second
I don't understand how is explanations related to my question. Its very good for me if you can make some hand made code or algorithm to understand basics. so that I can try to fix issues. I am not getting what are you doing.
Code:
#include <REG51.h>
#define
void main()
{
while (1)
{
//write your code here
}
}
Last edited: