A venus flytrap (Dionaea muscipula) after munching a mosquito.
-Photo by Matthew T. Ross-
The mechanism behind the closure of the trap is absolutely fascinating. If you look really closely in the above picture you can see hairs that lie within the trap. Here a picture of a closeup of one of the hairs:
Photographer: Martin Brunner, Source, Wikimedia Commons
Way back in 1961, Joseph R. Di Palma, Robert Mohl, and William Best Jr. recorded the action potential of the venus flytrap. That means that they were able to record the electrical signal that gets sent when a bug hits one of these hairs. The cool thing is that in order for the trap to shut, the insect needs to hit the hairs twice in succession before the trap will close. Since closing the trap costs energy, the plant wants to avoid false positives such a being hit by a raindrop.
Sources:
http://www.sciencemag.org/content/133/3456/878.short