Optogenetic techniques have been intensively applied to the nematode Caenorhabditis elegans to investigate its neural functions. However, as most of these optogenetics are responsive to blue light and the animals exhibits avoidance behavior to blue light, the application of optogenetic tools responsive to longer wavelength light has been eagerly anticipated. In this study, we report the implementation in C. elegans of a phytochrome-based optogenetic tool that responds to red/near-infrared light and manipulates cell signaling. We first introduced the SynPCB system, which enabled us to synthesize phycocyanobilin (PCB), a chromophore for phytochrome, and confirmed the biosynthesis of PCB in neurons, muscles, and intestinal cells. We further confirmed that the amount of PCBs synthesized by the SynPCB system was sufficient for photoswitching of phytochrome B (PhyB)-phytochrome interacting factor 3 (PIF3). In addition, optogenetic elevation of intracellular Ca 2+ levels in intestinal cells induced a defecation motor program. These SynPCB system and phytochrome-based optogenetic techniques would be of great value in elucidating the molecular mechanisms underlying C. elegans behaviors.