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.

[SOLVED] Avoid accidental press of button !

Status
Not open for further replies.

Raady Here

Full Member level 5
Joined
Jun 8, 2013
Messages
242
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Activity points
1,571
Hi,

I have configured a port pin which is connected to press button(switch), if high which I will start a motor.And for this I simply applied a condition
if (PORTB.RB6){
// loops for running motors.
}.

But I need to make avoidance of any accidental press. For this I need to hold the button for 3 seconds then motor should start.

How do I check if it is hold on press for 3 seconds or not ? Should I configure any timer for this ?
Any suggestions please.

MPLAB v8.8 / dsPIC30F5011.

Regards,
Raady.
 

You can calculate time from system clock.
To check Button is hold, you can make a loop 3 seconds: if Button is pressed, but in 3 seconds is released (to make sure button is released, you can count button state greater than your LIMITATION), set Button is HOLD.
If in 3 seconds, Button is kept in pressed state, set button is held and turn your motor.
 

if u want to avoid accidental press button then use on counter till like of 50/100 then u can detect the keys and proceed the your work. because as ur keeping 3 second is good for confirming but for continous use of ur keypad will really irritated someone if u want to use install in any product.

use counter
detect key
proceed the key and change it state.
 

you can do this

Code:
if (PORTB.RB6){
          delay for 3 seconds
          if (PORTB.RB6) //check again after delay 
          // loops for running motors.
}.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top