> For the complete documentation index, see [llms.txt](https://dkoudstaal.gitbook.io/raspberry-pi-worksheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dkoudstaal.gitbook.io/raspberry-pi-worksheets/chapter1.md).

# LED - Let there be light

In this activity you will connect a Light Emitting Diode (LED) to your Raspberry Pi's GPIO (General Purpose Input Output) Pins.

Warning!

* Make sure your circuit on your breadboard is not connected to your Pi
* Double check you circuit before you connect it to your Pi

After you have created the circuit you need to write a simple Pyhon program controlling the LED state being on or off.

Your program will introduce the concepts:

* importing modules
* setting GPIO pins
* variables
* user input from screen

## Equipment Used

![](https://253117239-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ln8HCViVOPYLhp39Uo7%2F-Ln8HCws3fVINCAepqGf%2F-Ln8HDLAd3L8_yjSSvhf%2FLED_2.svg?generation=1566745094555180\&alt=media) ![](https://253117239-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ln8HCViVOPYLhp39Uo7%2F-Ln8HCws3fVINCAepqGf%2F-Ln8HDLCOaUSxiWELppW%2Fbreadboard.svg?generation=1566745094672614\&alt=media) Electronics:

* One LED
* Breadboard
* Male to Female Breadboard Wires

## Raspberry Pi

The model Raspberry Pi we use is the Pi 3 Model B V1.2. Older models are compatible with our programs and electronic diagrams provided you use `GPIO.Board` for the pin numbering.

### Creating the circuit

![LED circuit](https://253117239-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ln8HCViVOPYLhp39Uo7%2F-Ln8HCws3fVINCAepqGf%2F-Ln8HDLECtJ2vK_nJy92%2FLedOne_bb.png?generation=1566745094656428\&alt=media)

The LED has to be connected in the right way. The electricity can only flow one way through a diode and a LED (a Light Emitting Diode). For the sake of this activity we assume the flow of electricity is from positive to negative. For a more correct explanation look at [this article](https://en.wikipedia.org/wiki/Electric_current) in WikipediA.

The anode (+) is the larger pin on the LED and the cathode (-) is the shorter pin. Also on the housing of LED is a flat part on the rim on the side of the cathode.

Pin 11 will supply the 3.3 volts to the LED when activated in your Python program.

Pin 6 is the ground pin completing the circuit when Pin 11 is turned on.

**Make sure your Pi is turned off from the power when you connect the LED circuit to your Pi!**

**Check the circuit before connecting the Pi to the power**

### A bit more about breadboards

![](https://253117239-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ln8HCViVOPYLhp39Uo7%2F-Ln8HCws3fVINCAepqGf%2F-Ln8HDLGASvrsirqo5Rl%2Fbreadboardexplained.svg?generation=1566745094807864\&alt=media) The vertical holes on each side of the breadboard are the Power Rails. There are four Power Rails. The holes on each Rail are connected.

The five holes on a Terminal Strip are connected.

Please note!:

* The four Power Rails are separate and NOT inter-connected.
* All Terminal Strips are separate and NOT inter-connected.
* The Terminal Strips are NOT connected across the Divider

The Divider is used for IC chips and to straddle parts such as switches, LEDs and chips.

[This site](http://computers.tutsplus.com/tutorials/how-to-use-a-breadboard-and-build-a-led-circuit--mac-54746) provides a more detailed explanation on the use of a breadboard.
