Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
i sure i m using 20Mhz crystal !!!
1 instruction = 4 clock cycle
time for 1 instruction=20 M/4 = 5 MHz
(unsigned long data) 5,000 x (my delay)1,000,000 = 5,000,000,000
5,000,000,000 / 5,000,000 cycles per second = 1000 seconds!
my calculation correct?
but result show is 5seconds???
void main()
{
unsigned long delay_time=5000;
for(;;)
{
if(SW1==0)
{
out=1;
delay(1000000);
out=0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this delay(1000000) is around 5 seconds
i m using 20MHz crystal...
my project is moving a car in and out
SW1 ON = car moving out for 5 second then automatic stop
SW2 or sensor ON=car go in for 5 second then automatic stop
when sensor OFF car will go out for 5 second then automatic stop
<<problem is i just allow this car stop at outside just for 30 second then...
for example i switch on a LED for 5 second then turn off for 5 second.
i keep repeating this process. now i want the LED just can turn on in total time of total 30 second(total 6 time off my process just now), then the LED wont be light on after this 30 second.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.