Can someone help me? I'm trying to control a fan using PWM and I cannot work out how to do it. This worked for a short amount of time and then stopped working.
According to the docs, GPIO pin 18 supports PWM.
To control it from the shell without root permissions, you need to install the wiringPi library. Take a look at the gpio docs or the man page for more information:
man gpioIn short: First set the mode of pin 18 to PWM:
gpio -g mode 18 pwmThen you can set the pin to a PWM value between 0 and 1023:
gpio -g pwm 18 512However, as Krzysztof already noted, you probably don't need PWM if you just want to send a short pulse. You could use a regular pin and simply turn it on and off every 2 seconds.
gpio -g mode 17 out gpio -g write 17 1 gpio -g write 17 0You could also control it from a program, e.g. a Python script. You should find information about this in the docs.
All this is untested, but should work. If you have more problems, feel free to comment or look at the or the manpage.