Hi
I have been trying to interface a 4x5 keypad on ESP32 with B4r but I cannot get it working.
It works fine with Arduino (1.8.13)
I have connected it to PINS:-
Array As Byte(36, 39, 34, 35), Array As Byte(32, 33, 25, 26, 27)
I know pins 36,39,34,35 are input only without internal pull-ups but I have fitted pull up resistors (3v3)
As I need the extra pins.
This configuration works fine on Arduino.
The code runs and after the 'AppStart' log, the first character in the string array is logged e.g. '<'
Every character can be logged by holding down the keypad key and pressing EN on ESP32 , it then returns the correct character after the reboot.
Any help would be greatly appreciated.
I have been trying to interface a 4x5 keypad on ESP32 with B4r but I cannot get it working.
It works fine with Arduino (1.8.13)
I have connected it to PINS:-
Array As Byte(36, 39, 34, 35), Array As Byte(32, 33, 25, 26, 27)
I know pins 36,39,34,35 are input only without internal pull-ups but I have fitted pull up resistors (3v3)
As I need the extra pins.
This configuration works fine on Arduino.
My version of code:
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")
'PINS 36, 39, 34, 35 are input only pins. I have put pull up resistors on all 4 pins
'After Appstart the first character in the init string is sent to logs e.g. '<'
'This Only works once when KP key is held down and the esp32 EN button is pressed and released
pad.Initialize("<741A0852B>963#@~v^*", Array As Byte(36, 39, 34, 35), Array As Byte(32, 33, 25, 26, 27),"pad_KeyPressed")
End Sub
'-------------------------- This works OK in Arduino ----------------------------------------------
'const byte ROWS = 4; //four rows
'const byte COLS = 5; //four columns
'//define the cymbols on the buttons of the keypads
'char hexaKeys[ROWS][COLS] = {
' {'<','7','4','1','A'},
' {'0','8','5','2','B'},
' {'>','9','6','3','#'},
' {'@','~','v','^','*'}
'};
'byte rowPins[ROWS] = {36, 39, 34, 35}; //connect To the row pinouts of the keypad
'byte colPins[COLS] = {32,33, 25, 26, 27}; //connect To the column pinouts of the keypad
'---------------------------------------------------------------------------------------------------
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
The code runs and after the 'AppStart' log, the first character in the string array is logged e.g. '<'
Every character can be logged by holding down the keypad key and pressing EN on ESP32 , it then returns the correct character after the reboot.
Any help would be greatly appreciated.