IR LED notes

Active today
Viewed 36 times

I’m using this circuit for my project, which I referred from https://www.sparkfun.com/news/1396.

enter image description here

enter image description here

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.


 New contributor

2 Answers



(1) How does current passes through the GPIO pins?

(2) Which GPIO pins should I connect to control an NPN transistor used to control the brightness of infrared LED lamp for Rpi camera photography?


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

You problem is mainly on:

(a) How much current is need to drive the 13 IR LEDs.

(b) Which GPIO pins to do PWM to control brightness of the LEDs.

I can use ordinary and IR LED to show the basic calculations.

/ to continue, …


(1) [NPN] Transistor as a Switch – Electronics Tutorials

(2) NPN Transistor – Electronics Tutorials

(3) Electronics Tutorial 4 Transistor Tutorial – YouTube

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

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: