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 CCS Technical Support

ALERT AND GETC() FUNCTION

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



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

ALERT AND GETC() FUNCTION
PostPosted: Tue May 10, 2005 8:13 am     Reply with quote

Hello,

i wondered how i could do if i want to something pretty much like this :

Code:
while(!END_OF_ALERT)
{
END_OF_ALERT = getc();
output_high(BUZZER);            // BUZZER ON
output_high(RED_LED);          // RED LED ON
delay_ms(5000);                   // ON for  5 seconds

output_low(BUZZER);             // BUZZER OFF
output_low(RED_LED);           // RED LED OFF
delay_ms(25000);                 // OFF for 25 seconds
}


The trouble is i would like the BUZZERand the RED LED switch on and off waiting while END_OF_ALERT is not 1, but the getc() function is waiting for a caracter on the serial port and doesn't move to this section ...

How can i do to this ? Do you have an idea ? Thanks a lot for your help !
Guest
Guest







PostPosted: Tue May 10, 2005 8:31 am     Reply with quote

Look at the function kbhit(). It will tell you if there is a character waiting, rather than waiting for a character.

SherpaDoug
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Tue May 10, 2005 8:48 am     Reply with quote

Ok, so it should be something pretty much like this ? :

Code:
while(!END_OF_ALERT)
{
if(kbhit())              END_OF_ALERT = getc();
output_high(BUZZER);            // BUZZER ON
output_high(RED_LED);          // RED LED ON
delay_ms(5000);                   // ON for  5 seconds

output_low(BUZZER);             // BUZZER OFF
output_low(RED_LED);           // RED LED OFF
delay_ms(25000);                 // OFF for 25 seconds
}
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed May 11, 2005 6:41 am     Reply with quote

That would work, though it would only check for the end of the alarm every ten seconds. If you shut off the alarm and it continues to blare for 9 more seconds most people would assume they failed to shut it off and resort to alternate means like kicking, throwing rocks, or cutting wires! Hold your breath for ten seconds to see how long it can be.
How about a loop that executes every 1/10 second checking if the alarn is supposed to be on or if it should be in mode one or mode two.
_________________
The search for better is endless. Instead simply find very good and get the job done.
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Wed May 11, 2005 7:57 am     Reply with quote

Hello,

how can i do that ? Do you have a code example Wink

Many thanks !
Scott
Guest







PostPosted: Wed May 11, 2005 8:29 am     Reply with quote

global wrote:
Hello,

how can i do that ? Do you have a code example Wink

Many thanks !



It would be quite similar to the Timer interrupt routine in your "Count 5 minutes if nobody logged in ..." thread

Scott
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