A simple example that uses a Timer to change the state of pin 13 (this is the pin connected to the built-in led):
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private Timer1 As Timer
Private pin13 As Pin
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
pin13.Initialize(13, pin13.MODE_OUTPUT)
Timer1.Initialize("Timer1_Tick", 1000) '1000ms = 1 second
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick
Dim currentState As Boolean = pin13.DigitalRead
Log("CurrentState: ", currentState)
Dim NewState As Boolean = Not(currentState)
Log("NewState: ", NewState)
pin13.DigitalWrite(NewState)
End Sub