Introduction: RPi Pwm Led Strobe
Here's a Raspberry Pi driving a bank of 72 leds in parallel. They are driven using pulse width modulation through a npn power transistor. The leds are from a 6v torch and there is no series resistor. Above 60 Hz they look on even with 10% duty cycle.
Step 1:
Python code for RPi to flash led via power transistor using PWM pin 25
#!/bin/bash
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(GPIO.OUT)
while True:
strobefreq = input("Frequency? ")
strobemark = input("Mark? ")
strobe = GPIO.PWM(25,strobefreq)
strobe.start(strobemark)
strobe.stop #never gets here
GPIO.cleanup