Hi everyone,
continuing my tests I test a button. This is the code of the program:
And these are the logs:
In these logs I 've never pressed the button.
When I press it it stays in :
0
Button not Pressed
and never see any millis. Am I doing something wrong or is it poor quality of the button?
Thanks in advance
continuing my tests I test a button. This is the code of the program:
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Dim tm As Timer
Private buttonin, buttonout As Pin
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
buttonin.Initialize(34, buttonin.MODE_OUTPUT)
buttonout.Initialize(35, buttonout.MODE_INPUT)
tm.Initialize("tm_Tick", 1000) '1000ms = 1 second
buttonout.AddListener("buttonout_StateChanged")
buttonout.DigitalWrite(False)
'Enable trigger with Timer interval
End Sub
Private Sub buttonout_StateChanged(State As Boolean)
Delay (300)
Log(State)
tm.Enabled = State
If State = True Then
Log("Button Pressed")
Else
Log("Button Not Pressed")
End If
End Sub
Sub tm_Tick
Log(Millis)
End Sub
And these are the logs:
AppStart
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
Button Not Pressed
1
Button Pressed
0
In these logs I 've never pressed the button.
When I press it it stays in :
0
Button not Pressed
and never see any millis. Am I doing something wrong or is it poor quality of the button?
Thanks in advance