I created a new project keeping this code:
GPIO example based on Things library:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ToggleButton1 As ToggleButton
End Sub
Sub...