Mikrokontrolery

 Program 'Long button press '

'***********************************
'*****   Long button press   *****
'*****       Tomasz Heilig     *****
'*****       IT/UP/06/2015     *****
'***********************************
Dim Flag As Bit

Config Timer0 = Timer , Gate = Internal , Mode = 1
Enable Timer0

Config Lcdpin = Pin , Db4 = POTRb.4 , Db5 = PORTB.5 , Db6 = PORTB.6 , Db7 = POTRB.7 , E = PORTB.2 , Rs = PORTB.3

Cursor Off

Cls
Lcd "Set the button"

Do
   Debounce P0.0 , 0 , Key , Sub
   Debounce P0.7 , 0 , Key2 , Sub
Loop
End

'################ Ver. 1 #################
Key:
Start Timer0
Bitwait P0.0 , Set
Stop Timer0

If Th0 < 5 Then
   Flag = 1
   Cls
   Lcd "No change"
Else
  Cls
  Lcd "Change code"
End If

Waitms 200
Th0 = 0
Cls
Lcd "Release the button"
Return

'################ Ver. 2 #################
Key2:
Waitms 250

If P0.7 = 0 Then
Wait 1
If P0.7 = 0 Then
Cls
Lcd "Change code:"
Waitms 200
Cls
Lcd "Release the button"
End If
End If

Return


Tomasz Heilig  ©  2023
Copyright © 2014
Designed by Free CSS Templates |
Darmowe Szablony