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 start an execution, only when INPUT by user?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Noobie
Guest







How to start an execution, only when INPUT by user?
PostPosted: Fri Mar 13, 2009 2:38 pm     Reply with quote

hie,

I'd like to create a program flow as:

If user push the push button, the program will start execute and end the program.
If no input from user, the program will wait till it detects the Input.
In another word, the program will need to wait for Input==1 by the user to start the program.

I've tried to use the 'for' function to create loop and wait for input. My code is:

Code:
   for(i=1;i>=1;i++){

      if(input(pin_C3)==1)
      {
         portb=0b10000000;
         delay_ms(1000);
         portb=0b00000000;

      }
      else if(input(pin_C3)==0)
      {
         i=1;
      }
   }


In my code, i tried to detect pin_C3 if there is any Input, the program will execute and end; else if no Input, the 'i' will equals to 1 and being loop bck till there is Input. However it doesn't goes like i espected on board Crying or Very sad

Anyone can help me on this matter?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 13, 2009 2:43 pm     Reply with quote

This post has a routine which will wait for a button to be pushed.
http://www.ccsinfo.com/forum/viewtopic.php?t=19874&start=1
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