I want to use THIS sample in my project. But its library is for pi4j version 1 and I use the pi4j version 2. I searched and I didn't find any sample for PCA9685 with pi4j2. Is there anyone who can help me?

  • You have two choices. Learn to program (pretty much the point of the Pi) or hire someone to write a program for you.
    – joan
    Aug 2, 2022 at 9:12
  • 1
    I would suggest to do the following to convert your already working pj4j1 program to pj4j2. (1) Test the pj4j1 program to make sure it is working for your rpi. (2) Study the pj4j1 program to see which pj4j2 I2C, GPIO functions (actually not that many, :))are used. (2) Convert the above couple of i2c/gpio functions one by one (3) Test the complete program using pj4j2 functions/class/library.
    – tlfong01
    Aug 2, 2022 at 10:00
  • @joan How can you write a program without required libraries?? I didn't say I don't know how to write code. I said I can't find the libraries. I know enough programming and if you don't have a solution, it's better not to answer! Aug 2, 2022 at 11:45
  • @tlfong01 Thank you. I would try your suggested ways. Aug 2, 2022 at 11:47
  • Essentially a duplicate of raspberrypi.stackexchange.com/questions/138446/…
    – joan
    Aug 2, 2022 at 11:54

1 Answer 1


Adafruit has a very nice guide on this with some easy to follow instructions. You can find it at" https://learn.adafruit.com/adafruit-16-channel-servo-driver-with-raspberry-pi" There are several tutorials on line to help you. I used "raspberry pi PCA9685" as the search term. This may not completely solve your problem but it is a good start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.