Welcome to EDAboard.com

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.

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
 

OlVi

Newbie level 4
Joined
Dec 4, 2003
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
45
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?
 

coshkun

Full Member level 2
Joined
Aug 27, 2005
Messages
126
Helped
18
Reputation
36
Reaction score
10
Trophy points
1,298
Activity points
2,214
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top