B4J Question GPIO button nanopi

irwan s

Member
hello, all ...
im newbie :)
i want to ask how to make if button press log will be change to press and not press will change to off..



B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub process_Globals
    Private button As neo2DigitalInput
    Public tmr As Timer
   
End Sub



Sub AppStart (Args() As String)
   
    button.Initialize("button",button.pin11)
        Log(button.ReadState)
    pressed
    StartMessageLoop
End Sub

Sub  pressed
   
    If button.IsON  Then
       
        Log("press")
    Else
       
        Log("off")
    End If

End Sub



'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

B4X:
Waiting for debugger to connect...
Program started.
off
 
Top