I'm trying to get pwm working by "dimming" an LED up and down:
Code: Select all
pin = 1 # only supported on this pin
for i in range(0,1024,16):
for i in range(1024,0,-16):
This does very much not work- the LED just stays on. The pin is correctly wired as using digitalWrite I can flash the LED.
I'm not a Python programmer, but I did write wiringPi
Before you use the single PWM pin on your Pi, you need to set it into PWM mode - and I don't see that in your code above - I do see you setting it to an output though. This won't work. Do whatever you need to do via the Python wrappers to set it into PWM mode. Maybe:
You also need to call some sort of wiringPi setup code too, but maybe you're doing this elsewhere.
And remember that there are 2 ways to initialise wiringPi - the wiring native mode uses pin 1 (which you're using here), or the hardware bcm-gpio mode when it would be pin 18.
(and I wish I've never bothered listening to people who wanted the bcm_pin numbering mode and stuck to wiringPi numbers, but that's another story!)