Hardware Required:
· Texas Instruments Launchpad
· Breadboard
· 15 Jumper Wires
· 10 330 Ohm Resistors
· 1 10K Ohm Resistor
· 1 Photo resistor
· 10 LEDs
Objective
In this lab, LEDs will be programmed to display how bright a room is. For example, if the photo resistor senses a dimly lit room, only one LED will be on, but if the photo resistor is exposed to bright light, all the LEDs will be on. We will be using digital and analog writes to accomplish our task.
The videos below show samples of the light sensing LED gauge working. All the LEDs will not be on all the time because the photo resistor is not sensing light that is bright enough, so the gauge will only show what is sensed.
What is Digital Write?
Computers are digital devices, meaning they perform all calculations using ones and zeroes. This method of computing is referred to as the "binary system," and is the heart of all digital technology. Devices such as hard drives, CD recorders, and Mini DV camcorders are digital devices, and therefore record data digitally, as ones and zeroes. This only allows the output to be set as either HIGH or LOW. Although it may seem very simple in that something is either on or off at a particular moment, it is still possible to create an illusion for something to seem halfway on. For example, an LED may be completely on or completely off, but if it turned on and off very rapidly, it would create the illusion that makes the LED look dimly lit. This is one method for making an output something different from completely on or off.
What is Analog Write and Pulse Width Modulation?
Another method for adjusting the intensity of an output is to use analog write, also known as PWM (pulse width modulation). After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle. Analog write is a much simpler method to adjust intensity because it allows the user to select a single value from a series. For example, setting an analog write value as 100 for an LED will make the light turn almost halfway on because LEDs range from 0 to 255, where 0 is completely off and 255 is completely on. Therefore, the LED has 255 steps of intensity. This range of numbers may be different for other devices, but the general function is the same.
How to Set Up Your Circuit
To set up your circuit you will need a Texas Instruments Launchpad (this example utilizes MSP432), a breadboard, 10 330 ohm resistors, 1 10k ohm resistor, 1 photo resistor, 15 jumper wires, and 10 LEDs. First you will need to place your LEDs right next to each other as shown below. Connect a jumper wire from each LED to analog write pins on the Launchpad. Next, connect your LEDs to ground by using 330 ohm resistors. Now, place your photo resistor on your breadboard, and connect one pin of the photo resistor to ground by using the 10k ohm resistor. Using another jumper wire to connect to ground, as seen below, may ease your process. Connect the other pin of the photo resistor to the voltage source (3.3 V). The last step is to connect the last two columns to ground and 3.3V on your Launchpad. Use the diagram below for help on setting up your circuit.
TROUBLESHOOTING:
· Check for errors in Energia debug window. The compiler will tell you what is happening. Errors are in red text.
· Sometimes your LaunchPad gets stuck or hung up on the previous code. Unplug your LaunchPad and plug it back in to perform a full reset. This is called a power on reset. Sometimes using the RESET button can work but taking away the power and letting the microcontroller fully reset is often best.
· If you have a failure to upload it could be your drivers are not properly installed. Energia will sometimes give the error “No unused FET Found” which means it can’t find a LaunchPad connected to your computer. Make sure you download the drivers for your operating system found on the Getting Started Guide.
· Make sure your pins are correctly connected. Use the diagram above to assist you.
· If your LEDs are not turning on, make sure the short leg of the LED is connected to ground and the long end to a pin on your Launchpad
Any comments or questions for better clarifications? Visit energia.nu/references
Comments
Please log in or sign up to comment.