For this week’s class, I decided to modify my light meter from last class using the microcontroller. Last week, one thing I was hoping to do with my light meter was to make it easier to read by having multiple lights light up as the amount of light hitting the meter increased. This seems like a much better interface, because it can measure specifically when light hits a specific point, and gives the user more concrete feedback than just how much electricity is flowing through a single LED. There was a certain irony in the fact that my last project was designed to tell the user how much light was hitting a sensor and in order to read it they would need too… look at how much light was coming out of an LED.
Thankfully, there was a video example in the class resources of people doing something similar to what I was hoping to accomplish using a photocell resistor. My first step was to connect the output of my light meter into the analog input of the Arduino. I did this by allowing one track of current to flow through a resistor into ground, and one track to flow through the detector into the A1 pin of the Arduino. The less resistance the detector gave, the more current would flow into the A1 pin.
Next, I needed to establish some “if” statements in my Arduino code to divide the amount of electricity it was receiving into six discrete categories (six was chosen somewhat arbitrarily), and if each category was met, to send a “high” signal to one of six pins on the actual board.
I chose to define each level at the beginning of my code based on what I read from the outside world. Level one was chosen by when my lights were turned off but the device was left uncovered reading ambient light. Six was chosen based on how much input it read when I shined my iPhone flashlight directly on it. Three was chosen when my room light was turned on, but it received no additional light.
Next, the actual board needed to be set up. I set up the same system for six LED’s hooked into the various pins, each with its own input and output coming from the board, and resistor to keep the light from burning out. Before attaching the lights to any of the output pins, I tested each of them on the regular positive and ground strips on the breadboard.
And they all worked! (I should mention that after testing, I did realize that I could have set this up using just one resistor to connect to a line of the breadboard and connect the lights in parallel downstream of that, but this was working and I didn’t want to mess with it.) I set it up to receive input from their respective output pins on the Arduino.
Ok, everything is set, let’s see if this works…
Excellent! Now it’s time to trim down the legs on the LED’s to make it a little less ungainly.
And there we have it! Light meter whose readout is calibrated with a microcontroller and can be read with an array of LED’s.