Science project

What Attracts Fruit Flies?


What foods attract fruit flies to your compost bin?


  • Four plastic bins with lids
  • Drill
  • Safety goggles
  • Soil
  • Red wiggler worms
  • Vegetable scraps such as lettuce and celery
  • Fruit scraps such as banana peels and apple cores
  • Camera
  • Shredded newspaper
  • Shredder
  • Spray bottle
  • Food scale
  • Notebook
  • Pencil


  1. Get two large plastic bins and get an adult to help you drill holes in the bottom. Make sure that you wear your safety goggles! Drill a quarter-inch hole every 5 inches or so.  Nest the bin with holes inside a bin without holes. Do the same thing with the other two bins. You’ve now created two worm bins – a type of compost bin.
  2. Shred enough newspaper or used white paper to cover the bottom of the bins, making sure that the bins are about halfway full of shredded paper. It’s best if you use a shredder to do this, but you can also use your hands to shred the paper into thin strips. Spray the paper with water to make it damp.
  3. Get yourself some worms! Red wiggler worms love to eat compost scraps. A pound of worms per bin is usually enough to start you out. Once you’ve placed the worms into their homes, decide which bin will have fruit and which one will have vegetable scraps. Write Fruit on one container and Vegetables on the other so you don’t get confused.
  4. Create a hypothesis, your best guess about what is going to happen. Which compost bin will attract and breed more flies: the one with vegetables, or the one with fruit?
  5. Put each bin in a shady place. These places should be at opposite ends of your house or garden.
  6. Now, add some food scraps to the bins. Green vegetables like lettuce and celery go into the vegetable bin, while fruit scraps like apple cores and banana peels go into the fruit bin. Weigh all of the food waste before it goes in so that you know you’re giving the worms in each bin the same amount of food. Be careful not to overfeed: Red wigglers can eat half their weight in food every day, so a pound of worms can eat half a pound of food a day.
  7. Over the next two weeks, visit each bin daily. Track and photograph what’s going on in each bin. What have the worms been eating? What do they seem to like best? Do the vegetable and fruit scraps disappear at the same rate?
  8. Check out the fruit fly population as well. Are there flies in or around either of the bins? Each day, count or estimate the number of flies that you see above each bin and write it down in your notebook. Does one bin have more flies than the other?


The bin with the fruit will have more fruit flies.


Like their name suggests, fruit flies love fruit. But why? The answer has more to do with the fruit’s sugar and starch than it does with the fruit itself.

Lettuce and celery have very little sugar or starch. This is one of the reasons that these vegetables are so good for you! However, sugars and starches are carbohydrates, one of the basic sources of energy that humans and other animals eat to live.  Most fruit has a lot of carbohydrates, often in the form of sugar.  Some vegetables also have a lot of more complex carbohydrates called starches. A potato is an example of a “starchy” vegetable.

Fruit flies might hang out on overripe fruit, but they’re really there for the yeast that grows on it. When starches in fruit begin to ferment, yeast uses those starches to make alcohol. Fruit flies are attracted to the CO2 produced by this reaction, and come to munch on the yeast. So if you have overripe fruit and starchy vegetables, the fruit flies will fly in for a picnic!

Fruit flies love fermenting fruit for another reason as well. In the wild, fruit flies are threatened by tiny wasps that lay eggs inside baby fruit flies, which can kill the fruit flies. Mother fruit flies lay their eggs in alcohol because alcohol helps kill those wasps. This provides the fruit fly babies with some protection.

How can you avoid ending up with fruit flies in the compost? Try the following techniques: Bury compost under a thin layer of soil or a thick layer of newspaper so that the fruit flies can’t find it. In an outdoor compost, add leaves or newspaper on top of the fruit to hide it and help it compost. Good composting methods will also heat up the compost, making it uncomfortable for the flies.

Disclaimer and Safety Precautions provides the Science Fair Project Ideas for informational purposes only. does not make any guarantee or representation regarding the Science Fair Project Ideas and is not responsible or liable for any loss or damage, directly or indirectly, caused by your use of such information. By accessing the Science Fair Project Ideas, you waive and renounce any claims against that arise thereof. In addition, your access to's website and Science Fair Project Ideas is covered by's Privacy Policy and site Terms of Use, which include limitations on's liability.

Warning is hereby given that not all Project Ideas are appropriate for all individuals or in all circumstances. Implementation of any Science Project Idea should be undertaken only in appropriate settings and with appropriate parental or other supervision. Reading and following the safety precautions of all materials used in a project is the sole responsibility of each individual. For further information, consult your state's handbook of Science Safety.

Add to collection

Create new collection

Create new collection

New Collection


New Collection>

0 items