Controlling the GPIO current

Each GPIO pin is only able to handle a certain current before it burns out (a maximum of 16 mA from a single pin or 30 mA in total), and similarly, the RGB LED should be limited to no more than 100 mA. By adding a resistor before or after an LED, we will be able to limit the current that will be passed through it and control how bright it is (more current will equal a brighter LED).

Since we may wish to power more than one LED at a time, we typically aim to set the current as low as we can get away with while still providing enough power to light up the LED.

We can use Ohm's law to tell us how much resistance to use to provide a particular current. The law is as shown in the following diagram:

Ohm's law: The ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.