Complex animal behaviors are built from dynamical relationships between sensory inputs, neuronal activity, and motor outputs in patterns with strategic value. Connecting these patterns illuminates how nervous systems compute behavior. Here, we study Drosophila larva navigation up temperature gradients toward preferred temperatures (positive thermotaxis). By tracking the movements of animals responding to fixed spatial temperature gradients or random temperature fluctuations, we calculate the sensitivity and dynamics of the conversion of thermosensory inputs into motor responses. We discover three thermosensory neurons in each dorsal organ ganglion (DOG) that are required for positive thermotaxis. Random optogenetic stimulation of the DOG thermosensory neurons evokes behavioral patterns that mimic the response to temperature variations. In vivo calcium and voltage imaging reveals that the DOG thermosensory neurons exhibit activity patterns with sensitivity and dynamics matched to the behavioral response. Temporal processing of temperature variations carried out by the DOG thermosensory neurons emerges in distinct motor responses during thermotaxis