CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to add a timer?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stef.df



Joined: 02 Apr 2009
Posts: 2

View user's profile Send private message

How to add a timer?
PostPosted: Thu Apr 02, 2009 7:56 pm     Reply with quote

Hi, can someone help me solve my problem.
My program is like:
Code:

if( input(PIN_C3)== true)
{ do............
}
else
{do..........
}

What I want to do now is add a timer so that when PIN_C3 is high, go to the if loop. When PIN_C3 turn to be low, after 1min go to the else loop.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 02, 2009 9:21 pm     Reply with quote

The easiest way to delay for 1 minute, if the program doesn't have to
do anything else during that time, is to do this:
Code:
delay_ms(60000);
Guest








PostPosted: Thu Apr 02, 2009 11:21 pm     Reply with quote

PCM programmer wrote:
The easiest way to delay for 1 minute, if the program doesn't have to
do anything else during that time, is to do this:
Code:
delay_ms(60000);


during the 1 min, still need to be in the if loop-.- after 1min jump to the else loop.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group