Jump to main content

Is It Ripe Yet? Build a Circuit to Detect Ripe Produce

546 reviews


When you go to the supermarket, how do you pick out ripe fruits and vegetables? You might look at their size or color, or feel them for firmness. That might be easy to do when you pick out a half dozen apples, but imagine if you had to examine thousands of apples growing in a field, or strawberries coming down a conveyor belt getting ready for packaging. Suddenly, it is a lot harder to do yourself! What if a machine could pick and sort the produce for you? In this project, you will address part of the problem by building a circuit that can differentiate between two colors.


Areas of Science
Time Required
Average (6-10 days)
Material Availability
Electronic circuit components required. See the materials section for details.
Low ($20 - $50)
Short circuits can get very hot. Follow the directions carefully to avoid short circuits.
Ben Finio, PhD, Science Buddies
Simple Color Detection Circuit


Electronically measure how light is reflected from different color surfaces, and build a circuit that can differentiate between red and green produce.


Many fruits and vegetables change color as they ripen. For example, tomatoes, strawberries, and red bell peppers all change from green to red. Color is just one way (along with size, texture, and smell) that you can tell if a fruit or vegetable is ready to be harvested or eaten. Imagine a factory that packs strawberries into plastic containers to be shipped off to grocery stores across the country. It might be useful to have a machine that automatically rejects any green strawberries that were picked before they were ripe. Or, you might want a machine on the farm that automatically recognizes strawberries by color and only picks the red ones to begin with. In this project you will build a circuit that uses visible light, which is the part of the electromagnetic spectrum our eyes can detect, to automatically differentiate between red and green objects.

Visible light comes in all the colors of the rainbow (which are measured by the wavelength of the light). Light can be reflected or absorbed by different surfaces (or transmitted through a transparent surface). The colors that we see in the world depend on what colors of light are reflected back to our eyes. White light (from the sun or most light bulbs) contains many different colors of light. When we look at a surface that is illuminated by white light, some colors are absorbed by the surface, and we see the color or colors that are bounced back. For example, an object that we see as red reflects mostly red light and absorbs the other colors (Figure 1, left). Objects that we see as white reflect all colors, and objects that we see as black absorb all colors. For a more detailed explanation of how humans perceive color, see the Bibliography.

Drawing of white light hitting a red and green wall and what colors will reflect back or be absorbed by the wall
Figure 1. When white light shines on a surface, some colors are absorbed, and other colors are reflected back to our eyes.

What happens if, instead of white light, you only shine a specific color of light on a surface? For example, if you shine a red light on a red surface, that red light will be reflected back. If you shine a red light on a green surface, however, the red light will be absorbed (Figure 2). If the green surface is only illuminated by red light, it will appear black.

Drawing of red light hitting a red and green wall and what colors will reflect back or be absorbed by the wall
Figure 2. Red light is reflected by a red surface and absorbed by a green surface.

You can use this information to build an electronic color-detecting circuit using a light-emitting diode (LED) and a photoresistor. An LED is a type of tiny light available in many different colors. A photoresistor is a special type of resistor. Resistors are electronic parts that resist the flow of electrical current (their resistance is measured in ohms [Ω]). A photoresistor's resistance depends on light—it has a high resistance in darkness and its resistance drops when exposed to light. When combined, a colored LED and a photoresistor can be used to differentiate between two different colors, as shown in Figure 3 (identifying any color requires multiple LEDs of different colors; see the variations section for more information). In this project, you will measure how a photoresistor's resistance changes when you illuminate different color surfaces with a red LED, and then use that information to build a circuit that can differentiate between red and green surfaces. Think of this as a first step toward building an automatic farming robot!

Drawing of red light hitting a red and green wall and a photoresistor measuring the reflected light
Figure 3. Schematic of how an LED and photoresistor can be used to detect the color of a surface by measuring reflected light. (Photoresistor and LED images credit Fritzing.org)

Terms and Concepts



Advanced students who want to learn more about circuits should read these references:

Materials and Equipment

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

Experimental Procedure

Build and Test Your Light-Measuring Circuit

  1. Assemble the circuit on your breadboard as shown in the slideshow (make sure you read the captions!) and Table 1.
    1. If you have never used a breadboard before, watch the How to Use a Breadboard video before you start building your circuit.
    2. Note that your jumper wire kit will come with a variety of colors. You do not need to use colors that match the diagram.
    3. Always connect the battery pack last when building a circuit. If you see or smell smoke, or any part of your circuit feels hot, immediately disconnect the battery pack. This means you have a short circuit and need to double-check your wiring.

Part Picture Notes
120 Ω resistor
Drawing of a 120 ohm resistor
(+) bus to F13
Direction does not matter
Clear red LED
Drawing of an LED with a clear housing
Long leg to J13
Short leg to J15
Direction matters, your LED will not
light up if you get the two legs reversed!
Drawing of a photoresistor
J16 to J18
Direction does not matter
Jumper wire
Drawing of a blue wire
(-) bus to F15
Color does not matter
Jumper wire
Drawing of a red wire
One end to F16
Leave other end free
Color does not matter
Jumper wire
Drawing of a black wire
One end to F18
Leave other end free
Color does not matter
A multimeter
Insert black probe into COM port.
Use alligator clip to connect it to jumper wire from F18

Insert red probe into VΩMA port.
Use alligator clip to connect it to jumper wire from F16

Set dial to "20k"
3xAA battery pack
Three double A batteries in a battery pack
Black wire to (-) bus (blue line on breadboard)
Red wire to (+) bus (red line on breadboard)
Table 1. Assembly instructions for the circuit. Image credits Fritzing.org.
  1. Set up the experiment as shown in Figure 4.
    1. Tape your breadboard to a piece of cardboard.
    2. Tape a cardboard box about 1 cm away from the edge of the breadboard. The exact distance does not matter, as long as it remains constant throughout your experiment.
    3. Bend the LED and photoresistor 90° to the side, so they both face the cardboard box.
    4. Cut a small piece of black construction paper and tape it around the edge of the photoresistor, so only the front face is exposed. This will help the photoresistor primarily measure reflected light, and not ambient light coming from other directions.
Overview setup of the color detection experiment and how all the electronics are connected

A battery pack powers an LED that shines a light at a colored paper. A light sensor directly beneath the LED measures the light reflected off of the piece of paper and a multimeter reads the output given from the light sensor.

Figure 4. Experimental setup for the light-measuring circuit.
  1. Cut squares (roughly 6x6 cm) from black, white, red, blue, and green pieces of construction paper. Test that you can prop the squares of paper flat up against the cardboard box without them falling over. If necessary, you can use tape to hold them in place.
  2. Even with the black construction paper wrapped around it, the photoresistor is still sensitive to ambient light levels. It is important that you do the experiment in a room with constant ambient light levels. For example, avoid doing the experiment on a partially cloudy day in a room with lots of windows, as light levels may fluctuate when clouds pass in front of the sun.
  3. Create a data table like Table 2 in your lab notebook.
 Resistance (kΩ)
Paper Color Trial 1 Trial 2 Trial 3 Average
Table 2. Data table for recording resistance values.
  1. Double-check your circuit. Make sure the battery pack is on, the LED is on, and your multimeter is connected and set to measure resistance in the 20 kΩ range.
  2. How to Use a Multimeter
  3. Place a black square of construction paper against the box in front of the resistor and LED. Read the resistance from your multimeter and record it in your data table.
  4. Repeat step 7 for each of the other colors.
  5. Repeat steps 7–8 two more times, for a total of three trials with each color.
  6. Calculate an average resistance value for each color and make a bar graph of your results.
  7. Analyze your results.
    1. Do you see a large difference in resistance between any two colors?
    2. Do any colors have about the same resistance?
    3. Imagine that the resistance value was the only information you had available (you could not actually see the surface you were measuring). Could you identify the color of the surface from that value alone?

Build a Circuit to Differentiate Red and Green Produce

In this section, you will use the information you learned in the previous section to build a circuit that can differentiate between red and green produce. It will light a second LED when red produce is placed in front of it, and the LED will stay off when green produce is placed in front of it (Figure 5). You will need to make some adjustments to get the circuit working perfectly. See the technical note for a more detailed explanation of how the circuit works (you do not need to fully understand how the circuit works in order to complete the project).

Drawing of an indicator light being lit up if a light sensor detects a reflected color

Color detection circuit concept showing two apple and two detectors. In the left-hand circuit, the detector shines LED light on a red apple, and a red LED activates singaling that the color red was detected. In the right-hand circuit, an LED light shines on a green apple, and the detector does not light (indicating that a different wavelength was detected).

Figure 5. Concept for a color-detecting circuit to separate ripe (red) and unripe (green) produce.
Technical Note

Figure 6 shows the circuit diagram for this circuit. It uses several additional parts that you did not use in your first circuit. See the advanced section of the bibliography to learn more about these components.

  • A potentiometer is a type of variable resistor. Its resistance can be adjusted by twisting a knob. The potentiometer is used to adjust your circuit's sensitivity to light.
  • The potentiometer is combined with the photoresistor to form a voltage divider. A voltage divider uses two resistors to take an input voltage (V1 in Figure 6) and reduce (or "divide") it by a certain amount. The output voltage (V2) depends on the values of the two resistors. In this circuit, those resistances depend on how much light is hitting the photoresistor, and how you have adjusted the potentiometer knob respectively. When more light hits the photoresistor, the output voltage goes up.
  • The output of the voltage divider is sent to the input of a transistor. A transistor acts like a valve that can control the flow of electrical current through something else, like a motor, buzzer, or LED. In this circuit, when the input voltage to the transistor exceeds a certain threshold (which occurs when enough light is reflected back to the photoresistor), it will cause a second LED to turn on.
Circuit diagram for connecting all the electronics needed for the color detecting experiment
Figure 6. Schematic for the color-detector circuit. If you do not know what these symbols mean, see the "How to Read a Schematic" reference in the bibliography.
  1. Assemble your new circuit as shown in the slideshow (make sure you read the captions!) and Table 3. Disconnect the battery pack while you are building your new circuit, and reconnect it at the end.

Part Picture Notes
Drawing of a photoresistor
J16 to J18
Direction does not matter
120 Ω resistor
Drawing of a 120 ohm resistor
(+) bus to F13
Direction does not matter
Clear red LED
Drawing of an LED with a clear housing
Long leg to J13
Short leg to J15
Direction matters; your LED will not
light up if you get the two legs reversed!
Jumper wires (6 total)
Drawing of a blue wire
(-) bus to F15
(+) bus to F16
(-) bus to A20
(-) bus to F27
E19 to F18
G18 to G25
Color does not matter
Drawing of a transistor
With writing facing to the left, pins in H25, H26, H27.
Direction matters!
Diffused red LED
Drawing of an LED that has red tinted housing
Long leg to E26
Short leg to F26
Direction matters!
120 Ω resistor
Drawing of a 120 ohm resistor
(+) bus to A26
Direction does not matter
The drawn symbol for a potentiometer
Holes D18, D19, D20
3xAA battery pack
Three double A batteries in a battery pack
Black wire to (-) bus (blue line on breadboard)
Red wire to (+) bus (red line on breadboard)
Table 3. Assembly instructions for the circuit. Image credits Fritzing.org.
  1. Now you will make some adjustments to get your circuit working properly. As described in the technical note, the diffused LED will turn on when the voltage V2 in the circuit exceeds a certain threshold. This voltage depends on two different factors:
    1. The resistance of the potentiometer, which you can adjust by turning the knob. This allows you to tune your circuit's sensitivity to light. The farther clockwise you turn the potentiometer, the more light is required to turn on the diffused LED.
    2. The resistance of the photoresistor, which gets lower when more light hits it. When the photoresistor's resistance is low enough, the diffused red LED will turn on. The exact amount of light hitting the photoresistor depends on many factors, such as:
      1. The distance to the surface being measured.
      2. The angle of the surface being measured (more light will be reflected back if the surface is perpendicular to light from the LED than if it is at a sharp angle).
      3. The relative position and orientation of the photoresistor and clear red LED.
      4. Ambient light levels in the room.
      5. How the photoresistor is shielded (for example, using black construction paper) from ambient light and direct (as opposed to reflected) light from the clear red LED.
  2. Your goal is to adjust the circuit such that the diffused red LED will only light up when you hold a piece of red produce in front of the clear red LED and photoresistor, but not when you use a piece of green produce, as shown in Figure 5. This lets you quickly identify whether a piece of produce is ripe just by looking at the LED. You can imagine how such a machine would be useful in a factory or farming setting to quickly and automatically identify, harvest, or sort ripe fruits and vegetables. Try adjusting some of the factors in the previous step to see if you can get the circuit to work to identify red and green produce. It may help to practice with squares of red and green construction paper first. How reliable is your circuit? Does it ever give a false positive (identify green produce as red) or a false negative (identify red produce as green)? See the variations section for more ideas about how to improve or modify your circuit.
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.
This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.


  • Try this project with a different color LED. For example, use a super bright green LED (Jameco part #2077079, use with 68 Ω resistor, part #690582) or blue LED (Jameco part #183222, use with 47 Ω resistor, part #690540). Note that these LEDs have a higher forward voltage drop so you will need to replace the 120 Ω resistor in the circuit as noted. How do your results change if you use a different color LED?
  • Try testing your circuit on a broader range of colored surfaces (yellow, cyan, magenta, orange, pink, etcetera). What colors result in similar resistance values? What colors result in different resistance values? What colors can you use your circuit to clearly differentiate?
  • How do your results change with varying ambient light levels? Does the circuit work outside in direct sunlight? What about in a busy room where people walk by and cast shadows on the circuit? How realistic would it be to use the circuit in different settings, for example a setting with controlled lighting (inside a factory) versus an outdoor area like a field?
  • The circuit in this project is not designed to identify all possible colors. It is designed to differentiate between two known colors (meaning you assume you will only show the circuit red or green tomatoes, and that you will never show it a blue tomato). Can you design a circuit that can detect any color? Hint: your circuit will need three LEDs (the red LED from the materials list, and the blue and green LEDs listed in the first variation), or a single RGB LED (an LED with red, green, and blue LEDs all built in to the same packaging). This task may be much easier with a microcontroller such as the popular Arduino™. Search online for "Arduino color detector circuit" or "Arduino color sensor" and you will find many examples.
  • Can you accomplish color detection using a webcam and computer vision instead of a circuit? What are the advantages and disadvantages of each approach?
  • As discussed in the background, there are other ways that you can tell if produce is ripe, like size, firmness, or smell. Can you design a different circuit that uses one of these methods to detect ripe produce? A photoresistor is an example of an electronic sensor that measures light. There are a variety of other sensors available that can measure things like distance, pressure, or the presence of certain gases. Do some research on these sensors and determine which ones you could use.


If you like this project, you might enjoy exploring these related careers:

Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Career Profile
There is a fraction of the world's population that doesn't have enough to eat or doesn't have access to food that is nutritionally rich. Food scientists or technologists work to find new sources of food that have the right nutrition levels and that are safe for human consumption. In fact, our nation's food supply depends on food scientists and technologists that test and develop foods that meet and exceed government food safety standards. If you are interested in combining biology, chemistry,… Read more
Career Profile
As the world's population grows larger, it is important to improve the quality and yield of food crops and animal food sources. Agricultural technicians work in the forefront of this very important research area by helping scientists conduct novel experiments. If you would like to combine technology with the desire to see things grow, then read further to learn more about this exciting career. Read more
Career Profile
Who works to protect the public health from food-borne illnesses? Agricultural inspectors. Everyone needs to eat, and agricultural inspectors work to ensure the quality and safety of the food supply to determine if they are in compliance. They also inspect farms, businesses, and food-processing plants to determine if they are in compliance with government food regulations and laws. Read more

News Feed on This Topic

, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Is It Ripe Yet? Build a Circuit to Detect Ripe Produce." Science Buddies, 26 Oct. 2023, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p088/electricity-electronics/build-a-circuit-to-detect-ripe-produce?from=Blog. Accessed 6 Dec. 2023.

APA Style

Finio, B. (2023, October 26). Is It Ripe Yet? Build a Circuit to Detect Ripe Produce. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p088/electricity-electronics/build-a-circuit-to-detect-ripe-produce?from=Blog

Last edit date: 2023-10-26
Free science fair projects.