O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using GPIO Pins as Outputs

We showed in Chapter 14 how the GPIO lines could be made to act like a switch between the 3V3 power rail and the ground. Now it’s time to put that into action and use that switch to control something. The first thing you should control is a simple LED. We say they’re simple because they are ubiquitous nowadays, but they still require a little explanation. The letters stand for light-emitting diode.

You probably understand the first two words, but the last one might need explaining. A diode is an elecPIO.setwarnings(False) # to remove spurious warnings on re runtrical component that lets current pass in one direction but not in the other direction, a bit like a non-return valve. The symbol tells a little story about this because the current arrives on the long side of the triangle, called an anode, and gets squashed down to a point and out through the barrier at the other end, the cathode. Current flowing in the other direction towards the cathode hits the barrier and can’t flow through the device. In a diode, the current flows from the anode to the cathode, as shown in the following image.

9781118554234-un1601.eps

In an LED, the current does exactly the same thing, but as it flows, it also generates light. In a normal incandescent bulb, light is generated because the filament gets hot and glows white-hot. In an LED and fluorescent light tube, the light creation mechanism is different. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required