Sub Process_Globals
Public Serial1 As Serial
Private pinButton As Pin 'pin for the button
Private pinLED13 As Pin 'pin for the green Led
Private LightOn = False As Boolean
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
pinButton.Initialize(pinButton.A0, pinButton.MODE_INPUT_PULLUP) 'Using the internal pull up resistor to prevent the pin from floating.
pinButton.AddListener("pinButton_StateChanged")
pinLED13.Initialize(13, pinLED13.MODE_OUTPUT)
pinLED13.DigitalWrite(LightOn) 'sets LED13 according to LightOn
End Sub
Private Sub pinButton_StateChanged (State As Boolean)
If State = False Then 'remember, False means button pressed.
LightOn = Not(LightOn)
pinLED13.DigitalWrite(LightOn)
End If
End Sub