B4J Code Snippet [IoT] Raspberry 2/piFace: Outputs

KMatle

Expert
Licensed User
Here's another example: How to use the outputs:

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

Sub Process_Globals
 
   Private controller As GpioController
   Private OutPin0 As GpioPinDigitalOutput
End Sub

Sub AppStart (Args() As String)
   controller.InitializePiFace(0x40, 0)
  
   'Init: false=pin is off, true=pin is on
   OutPin0.Initialize(0,False)
 
  'Switch it on (stays on)
   OutPin0.State=True
 
  'Switch it off (stays off)
   OutPin0.State=False
 
   'Switch it on for 5 secs
   OutPin0.Pulse(5000)
   Log("On")
 
   'Switch it off for 5 secs
   OutPin0.Blink(5000)
   Log("Off")
  
   StartMessageLoop
End Sub
Depending on your idea, you can initialize an output as "on" or "off". After that you can change the status or change it "for just a few secs" to off/on.

Note: I just copied the available commands to this example!
 
Top