RELAY-LINK

繼電器模組

內置兩組250V/5A
Slot
   0 1 2 3
4 5 6 7
 

B4R = Basic4Arduino

Libraries Manager  rCore
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 btnA6 As Pin
  Private btnA7 As Pin
  Private n1 As Int=1
End Sub

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

  btnA6.Initialize(btnA6.A6,btnA6.MODE_OUTPUT) 
  btnA7.Initialize(btnA7.A7,btnA7.MODE_OUTPUT) 
  CallSubPlus("RelayON",1000,1)
End Sub


Sub RelayON (Tag As Byte)
  Private b1 As Boolean

  n1=n1+1
  If n1>4 Then n1=0
  b1=False
  If Bit.And(n1,1)>0 Then
    b1=True
  End If
  Log("b1 =",b1)

  btnA6.DigitalWrite(b1)

  b1=False
  If Bit.And(n1,2)>0 Then
    b1=True
  End If
  btnA7.DigitalWrite(b1)
  Log("b2 =",b1)

  CallSubPlus("RelayON",1000,Tag)
  Log("value =",n1)
End Sub 
 
程式說明
14,15 Initialize(btnA6.A6,btnA6.MODE_INPUT)
  初始化物件
16,40  CallSubPlus("RelayON",1000,1)
  AppStart,RelayON執行後, 經過1000ms(1sec)再呼吸RelayON一次, 效果跟Timer一樣