Abstract:
A photocell is a light dependent resistor which is most resistive when the brightest light is illuminated on its surface and least resistive when little to no light is illuminated on its surface. In that sense, a photocell is a meter for the intensity of light.
Figure 1: Picture of a photocell
\”photocell-2\” by afternoon_sunlight is licensed under CC BY-NC-SA 2.0
This paper will discuss the accuracy of photocells in their ability to read fluctuating light intensity. The photocell will be subjected to 3 different light intensity patterns (in order of increasing complexity): square wave, triangular wave, and sine wave.
Figure 2: Three light intensity patterns illuminated by light source from least complex to most complex (all copyrights owned by author)
Even though some photocells have slightly different specifications, they all work and react to changing light intensities the same way[1]. Therefore, conclusions derived from this investigation can be applied to all other photocells. This investigation will analyze the photocell’s resistivity given each of the aforementioned light intensity patterns. Both the light intensities of the light source and the resistivities of the photocell have to be under the same scale so that the accuracy of the photocell can be easily assessed.
The brightness given by the light source and the resistance of the photocell will be scaled on a graph between 0-10 for the y-axis values. This means, the resistivity of the photocell will have a value of 10 when the brightness of the light source is 0 and vice versa. For the photocell to pass each of the 3 tests, its resistivity readings should be direct, or very close reflections of the light intensities over the horizontal line y = 5. This paper will include the results of each of the 3 tests, in the form of graphs, as well as a summary discussing the overall accuracy of a photocell.
Introduction:
This investigation all started with a fascination with streetlights. Interestingly, they only consist of a photocell and a light bulb which should stay off during the day and turn on during the night. It seemed like a very simple job for the photocell to only have to differentiate between bright sunshine during the day and pitch black at night. But what if the photocell had to look at all the light intensities in between pitch dark and sunshine? What if the full range of light intensities was illuminated in milliseconds rather than a whole day(24 hours)?
These queries put into question the accuracy of photoresistors. In order to assess the accuracy of photoresistors, a green light emitting diode (LED acting as the light source), photoresistor, circuit board, and Arduino’s integrated development environment(IDE) were used. This investigation aims to use both hardware and software to assess the accuracy of photoresistors.
Method:
Hardware Implementation:
The hardware components for this project included: a 5 volt battery, an Arduino microcontroller, a circuit board, 6 breadboard jumper wires, two 250 Ω (ohms) resistors, one sheet of aluminum foil, one green LED, and a photoresistor.
Figure 3: Circuit Schematic of dynamic LED and photoresistor (all copyrights made by author, image created using TinkerCad)
In this investigation, the green LED is the light source. It will illuminate three different light intensity patterns over time: square wave, triangular wave, and sine wave. As noted in figure 3, the photocell and LED are facing each other so that the photoresistor can change its resistivity based on the light intensity illuminated by the LED.
LEDs come in different colors such as red, blue, green and yellow. Therefore, when picking a LED, the ability of the photocell to read a specific color should be considered. Almost all photocells only read light with wavelengths between 400 and 600 nanometers(nm) [1]. This would mean photocells are the most accurate when the light has a wavelength of about 500 nm. Since green light has a wavelength of 500nm according to the color spectrum, the green LED is used in the circuit.
Each of the 6 breadboard jumper wires have a function integral to the current flowing where it needs to. Along each side of a typical circuit board are two sets of negative and positive rails. These exist because it\’s very common to connect components to power, ground, or both [2]. In this investigation the positive (red terminal), is used for connecting components to power and providing current whereas the negative (black terminal) is used for grounding. All 6 wires have a function and work in pairs. The white and balck wires together, the red and blue wires work together, and the yellow and orange wires work together.
The white and black wires are responsible for carrying power to both the LED and the photocell. The black wire directs current to the anode of both the LED and photocell. The anode is the leg of an electrical component that current flows into from an external circuit.
Without the white and black wires, the LED will not be able to illuminate different light intensities and the photocell will not be able to read different light intensities and adjust its resistivity accordingly. The red and blue wires are assigned to the cathodes of the LED and photocell respectively. They allow the current that previously entered the LED and photocell through the anode to leave. The digital input 9 and analog input A0 that the red and blue wires are plugged into are used by Arduino code to assign input number 9 to the LED and A0 to the photocell. The yellow and orange wires use the black, negative terminal to ground the current.
The circuit also takes advantage of resistors. Resistors are electrical components that slow down current in the circuit. They function to ensure that other components aren\’t provided with too much voltage or electric current [4]. The current flowing through the circuit should be equal to 20milliampheres (mA) or 0.02 amperes. This has been widely adopted in the field of engineering. 20 mA is the gold standard in industry because it can be run for long periods of time with minimal signal losses, will not be affected by load impedance or supply voltage, and has a low electromagnetic susceptibility [5]. The battery in this investigation has a voltage of 5 volts. Given this knowledge, Ohm’s law ( ) can be used to choose resistors with just the right amount of resistivity.
\\[R = V/I = 5V/0.02A = 250Omega\\]
Both of the resistors in the circuit have a resistance of 250 ohms (Ω).
Software Implementation:
In this investigation code is used to change the light intensity illuminated by the LED and read the resistivity values of the photocell. Code is also used to plot up the LED’s light intensity and photocell’s resistivity values, both on a scale from 0 – 10. As mentioned before, the resistivity of the photocell will have a value of 10 when the brightness of the light source is 0 and vice versa. The LED has a light intensity range of 0 – 255. [6] This means to scale the LED light intensity to 0 – 10, the light intensity has to be divided by 25.5. While the range of the LED is known, the scale of the photocell is not. A program has to be written to find the photocell’s highest resistivity and lowest resistivity value. See figure 5.
Figure 5: Arduino program to output lowest and highest photocell resistivity
This program was written to solve for the lowest and highest photocell resistivity values in ohms (Ω). Lines 1 and 2 are used to assign the LED and photocell to port 9 and A0 respectively. This is consistent with the circuit and hardware implementation. Lines 3 and 4 declare photocellReading (photocell’s resistivity values) and lightIntensity (LED’s light intensity) that will be used later in the program. They are float variables meaning they are numbers that have a decimal place. Numbers like 2.14 and 2.71 and examples of float variables. Floats are used when more precision is needed 7. Line 8 under the void setup () method initializes the serial connection at 9600 bits per second. It allows the computer and the circuit to communicate with each other. Lines 1 – 8 will stay constant for the 3 tests that follow. Line 14 makes the LED illuminate light at the highest intensity and has the photocell read that light intensity. Lines 17 and 18 print the lowest photocell resistivity value. Lines 22 – 29 have the same function and are very similar to the previous lines of code but instead of outputting the lowest photocell resistivity value, they output the highest photocell resistivity. This change is made in lines 22 – 23 where the LED illuminates the lowest light intensity or illuminates no light at all. Knowing the lowest and highest photocell resistivity values are needed to scale the resistivity values to 0 – 10. The program is compiled, and the output is printed below.
Figure 7: Output for above program – returns lowest and highest photocell resistivity values
Entering the lowest and highest photocell resistivity values into the Min/Max Normalization formula will scale the values from 20Ω – 346Ω to 0Ω – 1Ω.
\\[x_{scaled} = \\frac{x-x_{min}}{x_{max}-x_{min}}\\]
Figure 8: Min/Max normalization to scale values from 20Ω – 346Ω to 0Ω – 1Ω
The last step to scale values from 20Ω – 346Ω to 0Ω – 10Ω is to multiply the Min/Max Normalization by 10. This will scale the 0Ω – 1Ω values given by the Min/Max expression to 0Ω – 10Ω. The final expression to plot up graphically is below.
\\[\\frac{photocellReading – 20}{346-20}\\cdot 10\\]
Figure 9: Expression to be plotted up graphically with code to scale values 20Ω – 346Ω to 0Ω – 10Ω
Now that both the LED’s light intensities and photocell’s resistances are scaled from 0Ω – 10Ω, each of the 3 light intensity patterns (square wave, triangular wave, and sin wave) can be illuminated by the LED through code.
Test 1: Square Wave
The square wave test is the most simplistic out of the 3 tests – it is the easiest for the photocell to pass(2). Because the LED will only illuminate 2 values, full brightness and no brightness, and will keep its brightness for 200 loop iterations before switching to the opposite intensity, the photocell has the best chance to pass the first test. It should also be noted that the first derivative with respect to time of the light intensity, \\[\\frac{d(lightintensity)}{dt}\\]
, is 0 for 200 iterations at a time.
Figure 10: A square wave – the most simplistic wave out of the three wave illuminated by the LED
Figure 11: Test One (Square Wave) program
The first 8 lines of the Test One program are the same as the first eight lines to output the lowest and highest photocell resistivities. Line 13 uses a for loop to execute lines 15 – 23 200 times. There are 3 parts in a for loop: initialization, condition, and change8. The for loop in this program has an initialization of “int x = 0;”, condition of “x < 200”, and change of “x++”. The for loop increments x by 1 until x equals 200. This executes the lines of code under the for loop 200 times. Lines 15 – 18 illuminate the LED to the highest light intensity and have the photocell read the light intensity. Lines 19 and 23 plots up the LED’s light intensity and photocell’s resistivity values respectively, both scaled from 0 – 10. Line 21 prints the horizontal line of reflection y = 5. Because the resistivity of the photocell should have a value of 10 when the brightness of the light source is 0 and vice versa, the photocell will pass each accuracy test if its resistivity values are a direct, or very close, reflections over the line y = 5 to the light intensities. Lines 26 – 36 use the same for loop but instead of making the LED illuminate the highest light intensity, illuminate the lowest light intensity or none at all.
Test 2: Triangular Wave:
The triangle wave test is more complex than the first, square wave test but not as complex and difficult to pass as the sine wave test (2). Unlike the square wave test, in the triangular wave test, the LED will illuminate its full range of intensities rather than just full brightness and none at all. The LED will increment its light intensity at a constant rate until peak brightness is reached. At that point, the LED will decrease the intensity at the same constant rate it was just incrementing. It should also be noted that the first derivative with respect to time of the light intensity, \\[\\frac{d(lightintensity)}{dt}\\] , is a positive constant while the LED’s light intensity is incrementing. While the LED’s light intensity is decreasing, the first derivative with respect to time of the light intensity,\\[\\frac{d(lightintensity)}{dt}\\] , is a just the opposite of that constant. The second derivative with respect to time of the light intensity,\\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] , is 0 perpetually.
Figure 12: Triangular Wave – second most complex wave out of the three waves illuminated by the LED
Figure 13: Test Two (Triangular Wave) program
The Test Two program, like the Test One program, takes advantage of for loops. Line 11 initializes the LED’s light intensity equal to 0 and increases the light intensity every time lines 13-20 are executed. Lines 13 – 20 are executed over and over again until the LED illuminates it’s maximum light intensity – 255. At that point, the program decreases the LED’s light intensity the same way it increased it – through a for loop declared in line 23.
Test 3: Sine Wave:
The sine wave test is the most complex out of the three tests and consequently, the most difficult for the photocell to pass(2). Like the triangular wave test, the LED will illuminate its full range of intensities. The LED will increase and decrease its light intensity in the pattern of a sine wave. It should also be noted that the first derivative with respect to time of the light intensity, \\[\\frac{d(lightintensity)}{dt}\\] , is a cos(x) wave and the second derivative with respect to time of the light intensity, \\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] , is a -sin(x) wave perpetually.
Figure 14: Sine Wave – Most complex wave out of the three waves illuminated by the LED
Figure 15: Test 3 (Sine Wave) program
The for loop declared on line 14 iterates 360 times for the 360 degrees in 1 period of a sine wave9. For each iteration, the degree is incremented and the light intensity changes. Line 16 uses the value of variable degree to change the light intensity of the LED. Fortunately, Arduino’s integrated development environment (IDE) lets the programmer call a sin method that models data as sine wave. The IDE, however, only accepts units in radians – not degrees. Multiplying degrees with , changes the units from degrees to radians. In order to use PI (, the IDE needs the header #include <math.h> on line 1. Because the LED should illuminate the full range of light intensities, 0 – 255, the sine wave’s range should be 0 – 255. The equation below is the equation of a sine wave.
\\[y = asin(bx-c)+d\\]
Coefficients “” and “” influence the range of the sine wave. Coefficient “” is equal to the amplitude. The amplitude is half the range so . Coefficient “” is equal to the midline or the middle value in the range 0 – 255. This would make . Given this information,
\\[LightIntensity = 127.5\\cdot sin(\\frac{\\pi \\cdot degrees}{180}) + 127.5\\]
With this equation, the LED can illuminate the full range of light intensities ( 0 – 255) and can plot up scaled values (0 – 10) thanks to line 21.
Results:
The results of each of the three tests in this investigation are presented graphically. Each of the three tests have their own graph. Each graph has three curves: light intensities, photocell resistivity values, and the line of reflection, y = 5. Each curve will have its own color: blue for the light intensities, green for the photocell’s resistivity values, and red for the line of reflection.
Figure 16: Color coded key for the three different curves in each graph
For the photocell to pass each of the 3 tests, its resistivity readings should be direct, or very close, reflections of the light intensities over the line of reflection, y = 5. This means that both the light intensities curve and the photocell resistivity curve should intersect on the line of reflection. If the light intensities curve and the photocell resistivity curve intersect the line of reflection at very contrasting points, that is a sign of inaccuracy in the photocell. If the light intensities curve and the photocell resistivity curve have different shapes, first derivatives with respect to time, and second derivatives with respect to time, those are signs of inaccuracy in the photocell.
Test 1 Results: Square Wave
Figure 17: Graph Results of Test 1 (Square Wave)
Test 2 Graph: Triangular Wave
Figure 18: Graph Results of Test 2 (Triangular Wave)
Test 3 Graph: Sine Wave
Figure 19: Graph Results of Test 3 (Sine Wave)
Discussion:
With all 3 tests conducted in order of increasing complexity (square wave, triangular wave, and sine wave) and the data plotted up graphically, the photocell has provided very interesting results. Based on figure 17, the photocell has passed the first test (square wave test), exceeding expectations. The photocell’s resistivity values were always a direct reflection of the light intensities over the line of reflection.
The photocell failed the second test (triangular wave test) while providing promise for applications other than the streetlight. The photocell’s resistivity values, like intended, increased when the light intensities decreased and decreased when the light intensities increased. However, the rate at which the photocell’s resistivities increased and decreased (\\[\\frac{d^{2}(resistivity)}{dt^{2}}\\]) was opposite but not equal to the rate at which the light intensities increased and decreased -\\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] . \\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] is 0 as the light intensities increase and decrease at a constant reason. For that reason, the photocell’s resistivity values were not direct reflections of the light intensities over the line of reflection. Although the resistivity values followed the general pattern of the light intensities, figure 18 displayed hundreds of jagged lines as opposed to the single, uniform light intensity curve. This is due to the lack of sensitivity in the photocell. The photocell could not adapt as quickly as the light intensities changed – a factor to consider when examining possible applications for the photocell.
The photocell’s results for test 3 mirrored the results of test 2. Like in test 2, the photocell failed test 3 (sine wave test) while providing promise for different applications. The photocell’s resistivity values increased when the light intensities decreased and decreased when the light intensities increased like intended. However, \\[\\frac{d^{2}(resistivity)}{dt^{2}}\\] was opposite but not equal to \\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] . The concavity of the light intensities,\\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] , is constantly fluctuating from -1 to 1 as \\[\\frac{d^{2}(lightintensity)}{dt^{2}} = -cos(x))\\] and has a range of -1 to 1. This means that 50% of the time the light intensity curve is concave up and the other 50% of the time it is concave down. Meanwhile, based on figure 19, the photocell’s resistivity values curve is always concave down.
Figure 20: Concavity explained through second derivatives
Like in test two, the photocell was not sensitive enough to adapt to the constantly changing light intensities. However, because the magnitude of \\[\\frac{d^{2}(lightintensity)}{dt^{2}}\\] was generally less in test 3 than in test 2, there were less jagged lines in the results. This means decreasing the rate at which light intensities change will allow the photocell to measure light intensities more accurately – a factor to consider when examining possible applications for the photocell.
Conclusion:
The data indicates the photocell passed the first, simplest square wave test while failing the more complex triangular wave and sine wave test. Even though the photocell failed the second and third test, the findings indicate that the photocell can accurately recognize when light intensity is increasing and decreasing, just not how fast the light intensity is increasing or decreasing.
The biggest applications for the photocell are streetlights and burglar alarms9. This limits photocells to functioning digitally, only indicating whether light is present or not. Although right now photocells are only used for detecting the presence of light, with hours of time between presence of light and absence of light, photocells have many more applications. The data provides evidence for photocells being used in an analog fashion, to indicate the intensity of light.
For example, photocells, with the assists of heat cameras, can recognize and control forest fires before the fire begins to spread.
Figure 21: Person seen on heat camera – application of photocell
\”Heat Camera exhibit\” by the_exploratorium is licensed under CC BY-NC-ND 2.0
Photocells, attached to flying drones, can look specifically for orange, red, and yellow light (565nm – 740 nm). The photocells will be looking specifically for fire while filtering out everything else it sees. The data in this investigation suggests that photocells can sense when light intensity is increasing and decreasing. On that basis, the photocell can track the growth and spread of the wildfire as the originally black and purple area will turn red. Because of the stark contrast in purple and red, the photocell will accurately discern fire and land without fire. Once the photocell recognizes the forest fire, authorities can be contacted. The photocell will continue to aid the authorities by providing information about the growth and spread of the forest fire.
However, because the triangular wave and sine wave tests highlighted the insensitivity in photocells, there are many areas where photocells should not be applied, including x-ray and radiation detection.
Figure 22: X Ray – Limitations of photocells
\”X-Ray\” by Adrian Barnes is licensed under CC BY 2.0
With the light intensities varying so little, the photocell will not not be able to discern fractures or injuries accurately consistently – a risk that should not be taken when lives are on the line.
Acknowledgements:
This investigation would not be conducted without Mr. Taylor, physics teacher for instilling a passion for physics, electronics, and all things engineering. Much thanks to Mr. So, without whom the author would never understand programming language C. Dr. David Parent is very appreciated for mentorship and expertise in the world of electronics.
References:
- Ada, Lady. “Photocells.” Adafruit Learning System. Accessed September 6, 2020. https://learn.adafruit.com/photocells/overview.
- “Advantages and Disadvantages of Using a 4 to 20 MA Signal.” SensorsONE. Accessed September 6, 2020. https://www.sensorsone.com/4-20ma-use-advantages-disadvantages/.
- Cannaday, Brandon. How to Use a Breadboard. Losant IoT, January 29, 2020. https://www.losant.com/blog/how-to-use-a-breadboard.
- Foundation, Processing. “IntegersFloats \\ Examples \\ Processing.org.” Back to the Processing cover. Accessed September 6, 2020. https://processing.org/examples/integersfloats.html.
- “The Importance of \’Grounding\’ Electrical Currents.” Platinum Electricians, December 6, 2017. https://www.platinumelectricians.com.au/blog/importance-grounding-electrical-currents/.
- More, Hemant. Applications of Photovoltaic Cell. The Fact Factor, n.d.
- “Resistor.” Resistor – Energy Education. Accessed September 6, 2020. https://energyeducation.ca/encyclopedia/Resistor.
- Sterling, Mary Jane. “Adjusting the Period of a Sine Function.” dummies. Accessed September 6, 2020. https://www.dummies.com/education/math/trigonometry/adjusting-the-period-of-a-sine-function/.
- Tech, Georgia. “For Loops.” gatech.edu, n.d. http://ice-web.cc.gatech.edu/ce21/1/static/JavaReview-RU/LoopBasics/lFor.html.
- “Tutorial 10: Fade an LED with Pulse Width Modulation Using AnalogWrite().” Programming Electronics Academy, October 31, 2018. https://www.programmingelectronics.com/tutorial-10-fade-an-led-with-pulse-width-modulation-using-analogwrite/.
Figure References:
- Google.com. 2020. [online] Available at: <https://www.google.com/search?q=photocell+pictures&sxsrf=ALeKk013afk-S3XD8ArihlpNGOOiMXqX0w:1600824787506&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiL37mGkf7rAhUBA6wKHWebAskQ_AUoAnoECA4QBA&biw=1443&bih=1222#imgrc=g9QPeaDxVqB7_M&imgdii=NUrr0M0XSqRYKM> [Accessed 24 September 2020].
- “Sawtooth Wave.” Wikipedia. Wikimedia Foundation, June 30, 2020. https://en.wikipedia.org/wiki/Sawtooth_wave.
- Google Search. Google. Accessed September 24, 2020. https://www.google.com/search?q=visible+light%2C+ultraviolet%2C+and+infrared+with+wavelengths+spectrum.
- Google Search. Google. Accessed September 24, 2020. https://www.google.com/search?q=anode+to+cathode+current+flow+diagram+LED.
- Google Search. Google. Accessed September 24, 2020. https://www.google.com/search?q=heat+camera+wild+fire.
- Google Search. Google. Accessed September 24, 2020. https://www.google.com/search?q=xray+with+fracture+2+feet+one+with+crack.
About the Author
Ankit is a high school senior in California with a passion in computer science, electronic, physics, and all things engineering. In his free time, he loves to sing and play guitar, often playing for the seniors in his local senior home. He is really interested in aviation and hopes to have his own pilots license and plane one day.
Hi Ankit, well thought our design of experiments. Glad to see a young mind applying principles of physics and leading readers to a very practical and much needed application – fire detection. I am impressed with your dedication to science. Stay the path and continue asking questions. Proud of you!