The correct interpretation of threat and reward is important for animal survival. Often, the decisions underlying these behavioral programs are mediated by volatile compounds in the animal's environment, which they detect and discriminate with specialized olfactory neurons along their body. Caenorhabditis (C.) elegans senses chemical stimuli with neurons located in the head and the tail of the animal, which mediate either attractive or aversive behaviors. How conflicting stimuli are processed in animals navigating different chemical gradients is poorly understood. Here, we conceived, created, and capitalized on a novel microfluidic device to enable automated and precise stimulation of head and tail neurons, either simultaneously or sequentially, while reading out neuronal activity in sensory and interneurons using genetically encoded calcium indicators. We achieve robust and programmable chemical pulses through the modulation of inlet pressures. To evaluate the device performance, we synchronized the flow control with microscopy data acquisition and characterized the flow properties in the fabricated devices. Together, our design has the potential to provide insight into the neural circuits and behavior of C. elegans simulating the experience of natural environments.