Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Lcd still count numbers after releasing push button swicth

Status
Not open for further replies.

abofar

New Member
Hello,

Can someone help me please with this code. I am trying to enter a number by pushing the switch
but lcd continue displaying numbers for few seconds as if I did not release the switch (i.e add few numbers).
How can I stop lcd add numbers?.

Code for pic16f628A:

InsertHight:
select case hightswich
case 0
PAUSE 500
hight = hight+10
IF HIGHT>900 THEN
HIGHT=0
ENDIF
debounceH:
For i = 1 To 25
Pause 10 ' 10ms at a time so no interrupts are lost
Next i
UPDATE=1
GOTO DISPLAYH
DISPLAYH:
if (UPDATE=1) AND (HIGHTSWICH=0) THEN
Lcdout $fe,1," HIGHT "
Lcdout $fe,$C0," ",#hight," ","cm"
'WRITE HIGHT TO EEPROM
Write 2,HIGHT.BYTE0
WRITE 3,HIGHT.BYTE1
ENDIF
UPDATE=0
Goto inserthight
END SELECT
RETURN

Obaid
 
Last edited:
Pause 10ms * 25 , will debounce the switch.... but..... The human body is much slower than that. My debounce on my boards is about 250ms as well ( I buz a peizo to acknowledge a press... so they will let go)

It shouldn't affect you interrupts...That's what the're for .
 
Last edited:
Thank you Ian,
I did not understand " ( I buz a peizo to acknowledge a press... so they will let go)".

Do you mean to say I have to live with that, no solution,but the numbers set are not correct!.

Obaid
 
Sound a small beep to let the user know the key is pressed

If you press a button on a keypad ... Your finger will be there for around 300ms or so.... If this be the case, the program will have read the key several times before you let go..

If a button is pressed VERY VERY quickly you will never be able to just read it once...

Your code ...... button press...... 250ms debounce.... set press flag.... process.... re-set flag..... This will have run more than once in one keypress!

The idea of a buzzer is to acknowledge the key ( the humans first response is to let go when the sound is heard )
 
Last edited:
Thanks, again
If I want to set a number and I am looking at the display,I keep on pressing until I reach the the desired number then I stop pressing, the number increases 20 or 30, more than desired number. How can reduce this error or at least to certain extent . Is there another way of doing this?.
I cannot live with that it is too much it is large error in my case.

Obaid
 
Thanks Ian
I am sorry to bother you with my questions. I did what I suggested to do but the problem persist. Can you please show me on the code in my first post where to place while..wend and where to set and reset update. I promise you this will be my last question.
Thank you again

Obaid
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top