You configured your Starter Kit to control external devices in the first part of chapter four, so now it’s time to learn how to create the LED circuit itself on the breadboard.
When you wrote code to blink an LED in the first lesson, you really just wrote software. You didn’t build the LED circuit yourself. We can learn from that lesson however because the circuit that we are going to build here is at our disposal. We have the schematics! In Simplicity Studio, from the welcome screen, you can click on the tile that says Kit Documentation. When you open that tile, you will see an entry for the Wonder Gecko Starter Kit and the Schematics for the board. In the section for User Interface on page two, you can see the LED circuit for the LED that you controlled during that first lesson.
LED Circuit on the Wonder Gecko Starter Kit
The bus on the left called UIF_LED[1..0] can be traced back to port E, pins PE2 and PE3 on the MCU. (If you are curious, you can see that mapping on schematic page 3.)
In this circuit, the Starter Kit designers placed each of the User LEDs in series with a current limiting resistor. This resistor in series with the LED limits the amount of current that can flow through the entire circuit. Without these resistors, there is the potential to deliver too much current that could burn out the LED.
If you recall from the last lesson, we set the GPIO for the User LED to a high state to provide power to the LED. The MCU didn’t create that voltage, it merely acted like a switch that we controlled through our software. On one side of the switch was the LED circuit and on the other side was the source voltage for the MCU, which is 3.3V.
Equivalent Circuit of MCU as Switch
The maximum amount of current than can flow through this circuit can be calculated using Ohm’s Law:
V = IR
Where V = Voltage, I = Current and R = Resistance.
Since the MCU on the Starter Kit has a source voltage of 3.3V and we can see here that the resistors are 3k-ohm, by rearranging (remember algebra?) we can calculate the maximum current that can flow through this entire circuit is:
I = V / R = 3.3 / 3000 = 0.0011A or 1.1mA
The 1.1mA of current is a maximum value, as if the LED had zero ohms of resistance like a piece of hookup wire, which it is not. The LED has its own internal resistance, so that limits the current flowing through the circuit even more. For resistances in series with each other, they add up to create a bigger overall resistor between power and ground. The resistor is just a protection device to ensure that the LED doesn’t take more energy than is necessary for an indicator light.
The LED has a polarity that is shown in the following figure. In order to conduct electricity and emit light, it must be installed in the correct direction. Nothing bad will happen if you put it in backwards, but it won’t light up. In order for the LED to work, the anode has to be at a higher voltage than the cathode. How much voltage? The specs on each LED will tell you this in the forward voltage parameter but in general you will usually find that LED’s are in the range of 2V to 3.3V. You could operate them with slightly less voltage than that, but you should not dim an LED by reducing the voltage. We will cover the proper way to dim LEDs in the next lesson. You can also drive them from higher voltages, but in order to do that without destroying the LED, you will need to use a current-limiting resistor.
LED Schematic Symbol and Common Physical Device Polarity Markings
Therefore, to simply recreate the first lesson on your breadboard with your own LED and resistor, connect pin PD14 from your newly soldered header strip on the Starter Kit to the first column on the bread board. This will be the GPIO from the MCU that we will use to control the external LED. Place a 3k-ohm resistor sharing row 1 of the breadboard with the MCU control wire and the other side of the resistor to column 4. Install the single through-hole LEDs into the breadboard in columns 4 and 5, with the anode of the LED on column 4. The anode is the longer lead on the LED and the one that needs to be closer to a higher voltage than the shorter lead, the cathode. Connect the cathode column 5 of the LED to a pin marked GND on the Starter Kit.
LED Orientation and Breadboard Connections
Each column of holes on the breadboard connects all of the pins within that column together. Components on breakout boards with their pins on the bottom usually straddle the center separator, and then connections are made between devices by connecting multiple wires to each column of holes in the bread board on either side of the separator.
Breadboard Connection Diagram
Now, your circuit is complete, and we have duplicated the circuit that is shown in the starter kit schematics, but we need to change the software to control a different GPIO than the one that is connected to the onboard LED. We will cover that in the next lesson.