SELECT-LINK
品名 指撥模組
規格 內置兩鍵

B4R = Basic4Arduino

Libraries Manager  rCore
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private btnD5 As Pin
Private btnD6 As Pin
Private b1,b2 As Boolean
End Sub

Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")

btnD5.Initialize(5,btnD5.MODE_INPUT)
btnD5.AddListener("BtnD5_StateChanged")

btnD6.Initialize(6,btnD6.MODE_INPUT)
btnD6.AddListener("BtnD6_StateChanged")
End Sub


Sub BtnD5_StateChanged (State As Boolean)
b1=State
Log("SELECT = ",b1,b2)
End Sub

Sub BtnD6_StateChanged (State As Boolean)
b2=State
Log("SELECT = ",b1,b2)
End Sub
 
程式說明
20,23 Initialize(5,btnD5.MODE_INPUT)
  初始化物件
21,24  AddListener("BtnD6_StateChanged")
  指定狀態改變時會呼叫的事件名稱
28,33 Sub BtnD5_StateChanged (State As Boolean)
  事件副程式碼