In this unit, we describe an inexpensive and versatile method for optogenetic stimulation of a large population of genetically engineered Caenorhabditis elegans worms while quantitatively analyzing behavior. A custom light‐emitting diode light source is used to deliver blue‐light stimuli, causing direct depolarization of neurons expressing the light‐gated cation channel Channelrhodopsin‐2, which in turn evokes behavioral responses. The behavioral responses are recorded by a high‐throughput machine vision–based tracking system, the Multi‐Worm Tracker, for detailed analysis. This approach allows researchers to bypass technical obstacles to simultaneously deliver uniform stimuli to a large number of freely behaving animals and investigate the neural underpinnings of behavior. © 2018 by John Wiley & Sons, Inc.