xCeltix
Posts: 3
Joined: Sat Dec 31, 2016 1:03 pm

Multiple PWM pins array

Mon May 27, 2019 11:59 am

Is it possible to make an array of (software)PWM pins? I want to control multiple LEDs with PWM with only 2 buttons

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Multiple PWM pins array

Mon May 27, 2019 1:21 pm

You can send PWM to any combination of the GPIO. So you can have as many outputs as you have spare GPIO.

You can set them all to the same PWM values if you want.

You need to give more detail of what you are trying to achieve (especially the inputs and outputs).

xCeltix
Posts: 3
Joined: Sat Dec 31, 2016 1:03 pm

Re: Multiple PWM pins array

Mon May 27, 2019 1:49 pm

for example its possible to create a list for just GPIO

Code: Select all

leds=[10,9,11,5,6,7]
GPIO.setup(leds,GPIO.OUT,initial=GPIO.LOW)
But now i wanna do the same for PWM pins because its cleaner code, now i have to do this

Code: Select all

groen1=GPIO.PWM(leds[0],100)
groen2=GPIO.PWM(leds[1],100)
geel1=GPIO.PWM(leds[2],100)
geel2=GPIO.PWM(leds[3],100)
rood1=GPIO.PWM(leds[4],100)
rood2=GPIO.PWM(leds[5],100)
so I wanna know if its possible to declare them in a for loop and also start them with a loop?

Return to “Python”