Continue to Site

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.

pic16f877a push button

Status
Not open for further replies.

namratha_r

Newbie level 3
Joined
Jan 23, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
25
Hi am working on pic16f877a . Have interfaced pushbutton with pic I need help in programming.
If once switch is pressed it should increment one value and i achieved doing this its working fine .
But, condition is if switch is press down and hold for some time it should fastely and smoothly increment value without flickering but in my code if i press down and hold it will be in same state . anybody has any idea about the logic please help me.
Am using XC8 complier.
 

Most keyboard processing routines are based on a timer tic, e.g. 15 to 30 Hz. The button state is read once per timer tic to determine (debounced) key state, state change and duration of key press. Any complex reaction, e.g. value up/down with acceleration can be well based on it.
 

If button is pressed down and held for some time value should increment fastly how can i write code for this logic ?
 

below is part of my code...




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while(1)
{
 
   if(RA4 == 1)                           // switch       
            {
                oldstate = 1;             // flag is set
            }
                if(oldstate &&(RA4 == 0))
                {
                    val++;
                    if(val > 10)
                    {
                        val = 1;
                    }
 
                    oldstate = 0;
            }
}

 

You have state change detection but no debouncing.

For repeat function there must a timer that determines how long a key is pressed.
 

Thanks for quick response ...
but how to add that in this loop i dont no.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top