2

I'm working on a project that needs three (or more) PWM pins to work. But unlike Arduino, the Raspberry PI B+ has just one PWM pin. I've searched for solutions and I found that I can use the WiringPi to emulate PWM using software. Is this the best solution? Anybody has a better one?

Ghanima
  • 15,958
  • 17
  • 65
  • 125
bodruk
  • 187
  • 2
  • 8

2 Answers2

2

The Raspberry Pi B+ has two accessible dedicated hardware PWM channels.

Hardware timed PWM is available on all the accessible GPIO.

See my pigpio library.

joan
  • 71,852
  • 5
  • 76
  • 108
2

Studying the WiringPI library I found that I can easily handle the PWN on any pin:

# GPIO port numbers  
import wiringpi2 as wiringpi  
wiringpi.wiringPiSetupGpio()  
wiringpi.pinMode(25, 0) # sets GPIO 25 to input  
wiringpi.pinMode(24, 1) # sets GPIO 24 to output  
wiringpi.pinMode(18, 2) # sets GPIO 18 to PWM mode 
bodruk
  • 187
  • 2
  • 8