* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Master Notes
History of electric power transmission wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Stray voltage wikipedia , lookup
Immunity-aware programming wikipedia , lookup
History of electromagnetic theory wikipedia , lookup
Mains electricity wikipedia , lookup
Rectiverter wikipedia , lookup
Earthing system wikipedia , lookup
Alternating current wikipedia , lookup
Buck converter wikipedia , lookup
Ground (electricity) wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Current source wikipedia , lookup
Network analysis (electrical circuits) wikipedia , lookup
NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver Lesson 7: High/Low LED Driver Let’s go back to Lesson 3 where we had the Boe-Bot simulate a shuttle launch countdown (have the students pull up the program from their computers). At this point, your program should count down correctly, but we want it to acknowledge the completed countdown and the launch of the shuttle with something visual. Let’s simulate the shuttle launching by turning on an LED. Building the circuitry: Before we jump right into turning on the LED, we need to understand a little bit about the circuitry needed to make the LED turn on. The first component of the circuitry setup is the resistor. In a later class we will go into further detail on what a resistor is, but just know that there are many sizes of resistors that limit the flow of current through an electrical circuit. When turning on an LED, a resistor must be in place; otherwise, we run the risk of supplying too much current that will in turn burn up the LED. As you can see, each resistor has a specific color coding. Each color stripe indicates information about the total value of the resistor. The following resistor table helps you to know the size of the resistor being used. By using the chart, you can determine the resistance of a resistor from its colored stripes. The first stripe corresponds to the first digit, the second stripe relates to the second digit, and the third stripe corresponds to the number of zeros to the right of the second digit. The forth stripe is the tolerance of the resistor. The tolerance stripe is always a metallic color like gold or silver, so it is usually easy to distinguish which side of the resistor should be your first stripe. For example, a 470 (“” = the Greek letter omega, which is used to represent ohms, the units of resistance) resistor would be yellow-violet-brown with a metallic fourth stripe, where yellow represents a 4, violet represents a 7, and brown represents 1 zero that follows the resistor values Putting them all together, we must have a resistor of “470” ohms. NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver Now let’s figure out what a 220 resistor would look like. 2-Red 2-Red 1 Zero-Brown Thus, a 220 resistor will have the color stripes of: Red, Red, Brown. The next component that needs discussing is the breadboard. The breadboard is the white board with all the holes in it. The following graphic shows very briefly how a breadboard works. ` The third and final component to be discussed is the LED itself. The flow of current through the LED is unidirectional (meaning it can only travel in one direction), thus the LED must be positioned in the circuit properly. How can you tell if the LED in set up properly? There are two visual ways of determining the direction that an LED allows current to flow in: 1) The length of the leads The short lead is connected to the lower potential (ground). 2) The LED plastic casing The “flat” side on the base of the LED is connected to the lower potential or ground (This is useful to know when someone has previously cut one of the leads). NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver How do you turn on an LED? Vss Vdd 470 Ohm LED Notice how the resistor is plugged into the Vdd pin. The Vdd pin supplies the circuit with a regulated voltage of 5V (“V” stands for volts, the standard unit for voltage). If the resistor was plugged into a pin associated with Vin then the circuit would be supplied with the voltage value associated with the power source. For instance if you have 4 new AA batteries powering your BOE-Bot, each of which contains approximately 1.5 Volts, then Vin would supply 6 Volts. NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver What if we want to control the LED, when it turns on, how long it stays on, and so forth? To do so we need to incorporate the circuit into a program. Move the power lead to one of the pin numbers (The pin you place it in is arbitrary as long as you make sure you indicate the appropriate pin in your program. If you put the lead in pin 7 make sure your program uses pin 7). The microcontroller can now control when the pin is acting as a power source. On the left is a schematic of a simple circuit required to light the LED. The picture on the right is the circuit assembled on the BOE-Bot breadboard. Vss Pin 0 470 Ohm LED Notice from the picture how the resistor is plugged into pin 1. Each of the numbered pins in this column can individually be supplied with 5V when turned on in a PBASIC program. Let’s incorporate lighting the LED with our countdown program. Pull up the countdown program from the previous lesson into the PBASIC editor. At the end of the countdown, add a line of code that turns on the LED. This requires the HIGH command. The line of code should be as follows: HIGH # where the # is pin number that the resistor is plugged into. NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver This program, used in conjunction with the circuit we just built, will light an LED by sending a high signal (5 volts) to a pin. This voltage then passes through the resistor and the LED and then “sinks” to the ground. LED Discussion You may be wondering, “Why is the resistor in front? What if I put the resistor after the LED?” Well let’s see what happens when you hook up the following LED Direction: LED Vss Pin 0 Vss 5v 470 Ohm You can see that all we did was “flip” the entire circuit. Now test your program and the circuit. LED This diagram shows that the current is allowed to flow from higher potential (5v) to the lower potential (ground). The LED allows this current to pass through. What happened? Why did the LED not light up? The real question should be: What is an LED? LED Vss 5v This LED “blocks” the flow of this current. NASA-Threads Electricity and Magnetism Lesson 7: High/Low LED Driver LED stands for Light Emitting Diode. So it is a Diode that gives off light. But what is a diode? The most common function of a diode is to allow an electric current to travel in one direction and to block current in the opposite direction. This means that in our case, the electricity is “blocked” because of the direction of our LED. Pull out just the LED and “flip” the leads around so that the LED is still in front of the resistor as shown below. Vss Pin X 470 Ohm LED Now try your program and circuit. This time, your program should work. This demonstrates how you can turn on an LED using a high signal. *Just make sure you pay attention to the direction of the current flow and the LED!* Now that we know how to turn ON an LED using the HIGH command, we need to know how to turn the LED OFF. This is done by using the LOW command to make the pin output a voltage of 0 Volts.