Exercise 1.1: LEDs and Basic Circuits
Welcome to your first exercise in CCL's Introduction to Electronics course! If you haven't already, make sure you read through the course Home page to understand how the course is set up, and to see the exciting things you will get to build.
By the end of this exercise, you will build your first circuit where a DIP switch controls a seven-segment LED, and each switch will turn one segment on or off. If you don't know what these words mean, don't worry, you'll learn!
INSERT VIDEO OF SOMEONE MESSING WITH DIP SWITCH AND LIGHTS HERE
1) Power
To start us off, let's explore how our circuit gets powered.
Breadboard
This is a breadboard, a reusable board used to build and test electronic circuits easily. The holes in a breadboard are internally connected, so placing wires or components in the same numbered row connects them electrically. This means that a component in hole 27A is automatically connected to a component in 27E without needing a wire. The center gap keeps the left and right sides separate so components can be placed safely.
The long blue and red vertical side rails are also internally connected, and are typically used to connect to power.
Power Source
This is a 5V power source, which provides the energy needed for electricity to flow in a circuit. The 5V label describes the voltage of the circuit, which is the “push” that drives electricity through components. Voltage is measured in Volts (V). Current is what we call the flow of electric charge through the circuit, moving from the 5V power supply, through the components, and back to ground (0V). Current is measured in Amps (A).
Adapter
This is an adapter, allowing us to connect our power source to our breadboard. The adapter splits the power supply into a red and black wire. We call the side of the power supply with voltage the positive terminal and use red wires to identify it, while ground can be called GND or the negative terminal and is denoted with black wires.
By general convention, the red rail of the breadboard is used for the positive terminal of the power supply, and the blue rail is used for ground. Both rails of the breadboard are identical in hardware, but this convention ensures that as you work, you do not accidentally mistake the positive terminal for ground.
Note: If you connect the 5V terminal directly to GND, with no components in between, this creates a short circuit. Usually, the components between 5V and GND use up voltage. If the 5V and GND are connected directly to each other, energy from the power source cannot be dissipated, and will lead to large amounts of current flowing from 5V to GND which can permanently damage equipment.
Let's connect our breadboard!
1. Make sure your power source is OFF and not plugged into the wall.
2. Connect the adapter to the power supply.
3. Connect the red wire of the adapter to any hole in one of the red breadboard rails, and the black wire to the corresponding blue breadboard rail.
Current will only flow if the circuit is a complete loop, meaning there is a path directly from the positive (red) side of the power supply, through components, and back to the negative (black) side. If the loop is broken and there is an open circuit, electricity cannot flow.
2) LEDs and Resistors
Now, let's see how we can close this circuit to turn on an LED.
LED
This is an LED (light-emitting diode), a small electronic component that produces light when current flows through it in the correct direction. An LED has two legs. The longer one is called the anode, and the shorter one is called the cathode. The LED must be placed with the correct orientation, since it only allows current to flow one way, from the anode to the cathode. In this course, LEDs are used as lights, which help display information.
Resistor
This is a resistor, another component we can put between 5V and GND to complete our circuit. Resistors are used to limit how much current flows through a circuit. Resistance is measured in Ohms (Ω), and we can determine the size of a resistor by looking at the colors of the lines on the resistor, and inputting them into a resistor color code calculator.
By slowing down the flow of current, the resistor can protect other components, such as LEDs, which need less current to operate.
Safety
We are just about ready to make your first circuit! Before we continue, safety is very important when working with electronics, even in simple circuits like the ones in this course.
Always make sure there is a component, such as a resistor, between your positive terminal and ground. As we discussed earlier, if you connect 5V directly to ground with a wire, you create a short circuit. This allows large amounts of current to flow, which can overheat wires, damage components, or shut down your power source.
Keep all electronic components away from water or wet hands. Water can conduct electricity and cause short circuits, damage parts, or create a shock hazard. Always work on a dry surface and never use electronics near sinks, cups, or spills.
Do not connect your circuit directly to wall outlets or your home's power. Wall outlets have very high voltage (230V in India) and are extremely dangerous. You should only use low-voltage power sources such as 5V or 3.3V from a power supply, your computer's USB port, or a microcontroller.
Safety Tips:
- Turn your power off before changing wires or moving components.
- When power is on, keep your hands off of exposed metal components in the circuit.
- Never force components into the breadboard. Bent or broken pins can cause mistakes.
- If something feels hot, smells strange, or does not behave as expected, disconnect power immediately and check your wiring.
- When in doubt, ask for help or double-check the circuit before turning power back on.
Following these rules will help keep you safe and protect your components while you learn!
3) Turn On an LED
Time to connect our LED!
1. With your power OFF, connect one leg of the LED to the red positive rail, and the other to an empty horizontal row on the breadboard.
INSERT PHOTO OF LED IN BREADBOARD AND POWER RAILS CONNECTED TO ADAPTER
2. Connect a 220Ω resistor from the horizontal row that has the unconnected leg of the LED back to the GND rail.
3. Check that your wiring forms a complete loop of power source (positive) -> red rail -> LED -> resistor -> blue rail -> power source (ground).
Note: The order of the LED and resistor does not matter, as long as one goes after the other in the loop
4. Turn your power source ON. At this point, the LED should turn on! Congratulations on your first circuit!
If your LED does not light:
- Check the direction of the LED (it may be backwards).
- Check that one leg of the resistor is in the same row as one leg of the LED, and the other leg of the resistor is connected to ground.
- Check that you are using a 220Ω resistor.
- Check that the red rail of your breadboard is connected to the red wire of the power source, and the blue rail is connected to the black wire.
- Check that your power source is on.
- Try a different LED.
INSERT PHOTO OF LED ON IN CIRCUIT
4) Adjusting LED Brightness
We mentioned that we need a resistor to light an LED, because we need to limit the amount of current going through the LED to protect the component.
Let's do a mini experiment!
1. Make sure your power is OFF.
2. Remove your 220Ω resistor, and one at a time, test your circuit with a 270Ω and 330Ω resistor, turning the power ON each time to see the brightness of the LED.
5) Control Multiple LEDs
If we can turn on one LED, let's turn on eight! For this, we will need a bit more hardware.
DIP Switch
This is a DIP switch, which is a small set of on-off switches packaged together in one component. Each tiny switch can open or close a circuit, allowing or stopping current from flowing. We can use a DIP switch to manually turn individual LEDs on or off.
Jumper Wires
This is a jumper wire, which is used to make electrical connections between different points on a breadboard. By placing each end of a jumper wire into a hole, you connect those two rows so current can flow between them.
8 LED DIP Switch
Let's make our new circuit!
1. Make sure your power is OFF.
2. Using a red jumper wire, connect any hole of your connected red power rail to the other red rail on the breadboard. Using a black jumper wire, connect any hole of the blue ground rail you connected to the other blue rail on the breadboard.
Note: Now, both red rails are 5V and both blue rails are GND, so anytime you need to connect a component to 5V or GND you can use either side's rails.
3. Connect your DIP switch across the center gap of the breadboard, so that one row of the switch is sitting on one side, and the other row is on the other side.
INSERT PHOTO OF DIP SWITCH ACROSS THE CENTER BREADBOARD GAP
4. Connect 8 220Ω resistors to one side of the DIP switch, with each resistor having one leg connected to power and the other leg in one of the horizontal breadboard rows corresponding to the DIP switch.
5. Connect 8 LEDs to the other side of the DIP switch, with each one having one leg in one of the horizontal breadboard rows corresponding to the DIP switch, and the other leg in GND.
6. Turn power ON! You should now be able to control which of your LED lights are on by turning each DIP switch ON or OFF.
If your LEDs do not light:
- Check the direction of the LEDs (they may be backwards).
- Check that each of the rows of the DIP switch has a resistor on one side and an LED on the other.
- Check that you are using 220Ω resistors.
- Check that the red rail of your breadboard is connected to the red wire of the power source, and the blue rail is connected to the black wire.
- Check that both red rails are connected with a jumper wire, and that both blue rails are connected with a jumper wire.
- Check that your power source is on.
- Try a different LED.
6) Control a 7-Segment LED
For our last step of this exercise, let's connect our DIP switch to a 7-segment LED, allowing us to make numbers!
7-Segment LED
This is a seven-segment LED, which is a display made of seven small LED segments arranged in the shape of the number 8. By turning different segments on or off, the display can show numbers from 0 to 9.
1. Make sure your power is OFF.
2. Remove the 8 LEDs from your board, as well as one of the eight resistors. We only need seven resistors for a seven segment LED.
3. Next to the DIP switch, connect your 7-segment LED across the center gap of the breadboard, so that one row of the 7-segment LED is sitting on one side, and the other row is on the other side.
4. Using jumper wires, connect each pin from the empty side of the DIP switch (where the LEDs were) to one of the horizontal breadboard rows corresponding to the circled pins of the seven-segment LED. Leave the DIP switch row that doesn't have a resistor disconnected.
5. Connect the circled pin of the 7-segment LED to GND with a black jumper wire.
6. Turn power ON! You should now be able to control which of the seven segments turn on using the DIP switch, and make numbers!
If your 7-segment LED does not light:
- Check your power connections.
- Check the sizes of your resistors.
- Check that you are connecting to the correct pins of the 7-segment LED.
- If your circuit is still not working, try to mentally and physically walk through the circuit. Remember that your path should be a connected loop from the 5V power source -> components -> GND of power source.
Make sure you keep this setup for Exercise 1.2!
Final Submission
In the next exercise, you'll learn about binary and ICs to build a circuit that displays full numbers on the 7-segment LED.