I’m using this circuit for my project, which I referred from https://www.sparkfun.com/news/1396.
I don’t really understand how current works in GPIO pins, so the question is: instead of connecting them to pin 4, 6, 7, can I connect them to pin 4, 6, 12? as I need control over the brightness of LED and it seems I can only do that through the PCM_CLK pin.
The OP’s board question can be narrowed downed to 5 smaller questions:
(1) What is the maximum current of the IR LED Ring?
(2) Which transistor should be used to PWM adjust the LED ring brightness?
(3) Which PWM signal should be used to control the transistor switch?
(4) Which Rpi GPIO pin should be used?
(5) How to write the python program?
(3) Now I need to find a PWM signal to drive the power MOSFET.
(2) I read Electronics Tutorials on power MOSFET and found it a good idea to use it as a PWM switch to control IR LED ring lamp.
(1) I checked my 12V LED ring lamp and found the max current about 500mA. The lamp is a bit too weak. I am thinking of adding two more rings, white/yellow for day vision, another IR for night vision.
/ to continue, …
I would suggest to quickly skim through the newbie tutorials to get a very rough idea of GPIO, PWM, and transistor switches: Refs 1 to 3 are particularly related to your IR LED circuit.
(1) Rpi GPIO baiscs
(2) Transistor operation basics
(3) PWM basics
The OP’s question can be summarized as below:
(a) How much current is needed from the GPIO pin to drive the NPN transistor switch which in turn drives the 13 IR LEDs?
(b) Which GPIO pins to do PWM to control brightness of the LEDs?
I will be using ordinary (around 450 nm) and IR (850/940nm) LED to do the basic calculations.
/ to continue, …
End of answer
Yes you probably could. I’ve not heard of anyone controlling the brightness of infra red IRs before, but that might just be my ignorance.
However PWM signals can be generated on all the GPIO. The only advantage of using GPIO 18 (pin 12) is that like GPIOs 12, 13, and 19 it can be connected to the Pi’s hardware PWM peripheral.
See https://pinout.xyz/ for a diagram showing the mapping of GPIO to pins on the extension header.
As I say PWM can be generated on all GPIO.
My pigpio library has this feature. To generate PWM on GPIO 4 (pin 7) do
sudo pigpiod pigs p 4 64 # 1/4 dutycycle pigs p 4 128 # 1/2 dutycycle pigs p 4 192 # 3/4 dutycycle pigs p 4 255 # full on