B4J Question pi4j wiringpi

Fabrice La

Active Member
Licensed User
Longtime User
Here my problem
I am trying to use ServoMotor
If I do
  • gpio mode 1 pwm
  • gpio pwm-ms
  • gpio pwmc 400
  • gpio pwmr 1000
And to turn the servo from left to right
  • gpio pwm 1 48
  • gpio pwm 1 96
Every thing work like expected.

Now if I do
B4X:
Sub Process_Globals
    Private Gpio As JavaObject
End Sub

Sub AppStart (Args() As String)
    Log("Started")
    initServo
    StartMessageLoop
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

Sub initServo
    Gpio  = Me
    Gpio.InitializeStatic("com.pi4j.wiringpi.Gpio")
    Private fd As Int = Gpio.RunMethod("wiringPiSetup", Null)
    Log("wiringPiSetup " & fd) '0 = OK
    Gpio.RunMethod("pinMode", Array As Object (1, 2)) 'PWM_OUTPUT = 2
    Gpio.RunMethod("pwmSetMode", Array (0)) 'PWM_MODE_MS = 0
    Gpio.RunMethod("pwmSetClock", Array (400))
    Gpio.RunMethod("pwmSetRange", Array (1000))
    Log("Tour1")
    Gpio.RunMethod("pwmWrite", Array (1, 48))
    Sleep(2000)
    Log("Tour2")
    Gpio.RunMethod("pwmWrite", Array (1, 96))
    Sleep(2000)
    ExitApplication
End Sub
Not working ...
B4J 8.30
Java jdk-13.0.1
Raspberry 4B
 

roberto64

Active Member
Licensed User
Longtime User
Hello, must have the version of java 11.0.1 on b4j and the version 13.01 in rasberry, also I did various tests to understand which java could work and with these version and everything is ok
regards
 
Upvote 0

Fabrice La

Active Member
Licensed User
Longtime User
Hello, must have the version of java 11.0.1 on b4j and the version 13.01 in rasberry, also I did various tests to understand which java could work and with these version and everything is ok
regards
Thank you for the reply

I have
C:\Program Files\Java\jdk-11.0.1\bin\javac.exe
on windows and Path on B4J and
jdk-13.0.1/bin/java -jar
on the Raspberry ....
 
Upvote 0
Top