0

I'm currently developing an application with the WiringPi library. I have implemented a prototype in Python, and I'm currently trying to reproduce the same behaviour in C++. However, I ran into some issues.

In Python, I have the following code related to PWM:

p1 = GPIO.PWM(25, 1000)
p2 = GPIO.PWM(21, 1000)
p1.start(100)
p2.start(100)
...(some code)...
p1.ChangeDutyCycle(50)
p2.ChangeDutyCycle(50)

I'm trying to replicate the same behaviour with the WiringPi library in C++, but I can't find how to do it. I tried using the Software PWM Library (included in WiringPi, see here) without any success. Please note that softPwmCreate(...) returns 0 (which means success):

softPwmCreate(25, 100, 100);
softPwmCreate(21, 100, 100);
...(some code)...
softPwmWrite(25, 50);
softPwmWrite(21, 50);

Can anyone tell me what I'm doing wrong, and how I could use the WiringPi library to replicate my Python code?

Thanks!

  • the snippet should work .... check the rest of your code – jsotola Feb 21 at 3:01
0

As @jsotola says the snippets appear to be doing the same thing.

The most likely error is that RPi.GPIO and wiringPi are being configured to use a different GPIO numbering scheme.

RPi.GPIO supports Broadcom GPIO numbering and board numbering.

wiringPi supports Broadcom GPIO numbering, board numbering, and its own numbering scheme.

Check that you are using the same scheme in both libraries.

  • Thanks! Both you and jstola were right. The issue was in my GPIO wiring and did not come from the software. – mathlizee Feb 22 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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