Using lasers, Legos and an algorithm based on a classic spy trick, scientists have created a sensor that can instantaneously classify the insects that fly past it.

The invention offers a powerful and cheap new strategy for quickly identifying infestations that threaten agriculture and human health. Among other applications, the technique could lead to more targeted attacks that would reduce the load of pesticides needed to squelch invasions.

Encouraged by good results in the lab, entomologists are now beginning to test the system in places like Mali, where a massive search has yet to determine exactly where malaria-carrying mosquitoes hide out during the dry season.

Pests: What's Their Purpose, Anyway?

"This has the potential to save lives and crops," said Eamonn Keogh, a computer scientist at the University of California, Riverside. "My feeling is that in the next year or two, there will be a lot of applications for this."

Every year, insects kill millions of people by transmitting diseases, and they destroy more than $40 billion of food crops. For nearly 70 years, scientists have been looking for efficient ways to detect infestations as soon as possible to mitigate the damage, but they've repeatedly run up against roadblocks.

Many previous attempts to create automated insect detectors have attempted to use sound to identify insects, but acoustic microphones are limited by distance. The farther away a flying critter is, the less volume a mic will pic up, making the technique useless unless insects fly right in front of the system.

Photos: Animals and Bugs That Look Like Flowers

Instead, current methods for surveying insects have remained inefficient and laborious. Scientists often set out sticky-paper traps and then send someone out every week to check and identify what has landed on the paper. Some insects only live for a week or two, so by the time the technician arrives, it may already be too late to beat the infestation. It's also easy for human eyes to make mistakes because so many species look extremely similar to each other.

In search of a better system, Keogh and colleagues turned to a classic James Bond-style spy trick. When a person standing near a glass window speaks, he explained, the glass vibrates. If you want to eavesdrop, you can shine a light on that glass and use the vibrating reflections to interpret what is being said.

Like a spy detector, the new bug-sensing device shines a laser-thin line of light against a board that converts light fluctuations into sounds. These sounds get recorded as MP3 files, which can then be analyzed by a computer program.

A close-up view of a Brown marmorated stink bug -- a common crop pest.Lildobe/Wikimedia Commons

In the recordings, the program can listen for the frequency of wing-beats, which varies from species to species and even between males and females of some species, Keogh said. The team describes the new sensor in a paper currently under review by the Journal of Insect Behavior. Using frequency alone, the program can classify an insect with about 80 percent accuracy.

To make the system even more precise, the algorithm can also be programmed to factor in temperature, humidity and other environmental clues as well as behavioral quirks of various insects, like the time of day they are usually active and the height at which they like to bite.

Biodiversity in the insect world is massive and Keogh's team hopes to build a massive collection of identifiable species by enlisting the help of the public, including elementary schools, where each class could collect data on a single species. The researchers are also working to build the sensors out of Legos, which would make them easy to fix in the field and as cheap as a dollar each.

7 Insects You'll Be Eating in the Future

Potential applications are wide-ranging. In the wild, sensors could track bees to help scientists figure out how colony collapse disorder might be spreading. In orchards, the devices could detect when and where crop-eating insects appear so that farmers could immediately respond with targeted spraying.

In the fight against disease, sensors could be used to identify which of the 3,528 species of mosquitoes just flew through the door of a home so that researchers might know whether the kind that spread malaria are around. Only female mosquitoes bite, so the sensors could also be used to pick out and release only the males form a sterilized population -- a technique that has shown promise in causing population numbers to plunge.

In Mali, entomologist Tovi Lehmann hopes the system will help solve a longstanding mystery. Every year, malaria-carrying mosquitoes disappear during the dry season for up to seven months. But as soon as it rains, they show up instantly. Despite using large human search teams as well as dogs trained to sniff out mosquitoes, scientists still haven't figured out where the mosquitoes go when the rains stop.

Cellphones Track Malaria in Kenya

If the sensors can be built to stand up to harsh conditions, they could reveal where the mosquitoes hide, possibly allowing for total eradication.

"At this point, we are testing a prototype," said Lehmann, of the Laboratory of Malaria and Vector Research at the National Institute of Allergy and Infectious Diseases in Rockville, Maryland. "The promise is great and I am very enthusiastic about it. They just need a little more work to make them field-ready."