Need info please guide me

Status
Not open for further replies.

kalpana.aravind

Junior Member level 3
Joined
Jan 13, 2006
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,605
Hi everyone,

I want to know about considerations about switch bouncing & debouncing in writing programs while using a switch to turn on LED or Buzzer.
How should i take it into consideration when writing the program.
Please mail me some example code if possible.
Any reference books or websites useful in embedded C programming, mail to me.

Thanks in advance,
Kalpana
 

In one project (only 2 keys) I used timer for debouncing: read key once every 50ms, if key was previously down (key=1), there must be at least two key reads with key up (key=0) to accept next key press (hope you understand... it is difficult to explain.)

Is analog debouncing option?
 

We,human beings, can't press a button more than 10 times in second.So it's enough to scan for a key press for 100 msecs.For example:
Example: (toggling the LED)
Code:
#include <16F84A.h>
#fuses XT,NOWDT,NOPROTECT
#use delay(clock=4000000)

#define BUTTON    PIN_B0
#define LED    PIN_B3

void main()
{
output_low(LED);
delay_ms(100);

   while(TRUE)
   {
      if(input(BUTTON)==0)             // The time the button is pressed
      {
         output_toggle(LED);
         delay_ms(20);

         while(input(BUTTON)==0);      // wait until the button is released.
      }
   }
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…