Sub Process_Globals
Public Serial1 As Serial
Private pad As Keypad
Private password As String = "123456" 'the password is *123456
Private passwordBuffer(6) As Byte
Private passwordIndex As Int
Private bc As ByteConverter
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'matrix keypad is a 3X4 , not 4X4, but I think is same, assuming has only 3 cols and 4 rows.
pad.Initialize("123456789*0#", Array As Byte(14,12,13), Array As Byte(5, 4, 0, 2), "pad_KeyPressed")
'''pad.Initialize("123456789*0#", Array As Byte(14,12,13), Array As Byte(1,3,5,4), "pad_KeyPressed")
'this is only a combination, I've tried a lot of them...
End Sub
Sub Pad_KeyPressed (Key As String)
log(key)
If Key = "*" Then
passwordIndex = 0
'this is not really required, but it makes the logs nicer.
bc.ArrayCopy("000000", passwordBuffer)
Else if passwordIndex < passwordBuffer.Length Then
'put the key in the buffer.
passwordBuffer(passwordIndex) = Asc(Key)
passwordIndex = passwordIndex + 1
If passwordIndex = passwordBuffer.Length Then
If passwordBuffer = password Then
Log("Well done!!!")
End If
End If
End If
Log(passwordBuffer)
End Sub