AbstractTo survive in a complex and changing environment, animals must adapt their behavior. This ability is called behavioral flexibility and is classically evaluated by a reversal learning paradigm. During such a paradigm, the animals adapt their behavior according to a change of the reward contingencies. To study these complex cognitive functions (from outcome evaluation to motor adaptation), we developed a versatile, low-cost, open-source platform, allowing us to investigate the neuronal correlates of behavioral flexibility with 1-photon calcium imaging. This platform consists of FreiBox, a novel low-cost Arduino behavioral setup, as well as further open-source tools, which we developed and integrated into our framework. FreiBox is controlled by a custom Python interface and integrates a new licking sensor (strain gauge lickometer) for controlling spatial licking behavioral tasks. In addition to allowing both discriminative and serial reversal learning, the Arduino can track mouse licking behavior in real time to control task events in a submillisecond timescale. To complete our setup, we also developed and validated an affordable commutator, which is crucial for recording calcium imaging with the Miniscope V4 in freely moving mice. Further, we demonstrated that FreiBox can be associated with 1-photon imaging and other open-source initiatives (e.g., Open Ephys) to form a versatile platform for exploring the neuronal substrates of licking-based behavioral flexibility in mice. The combination of the FreiBox behavioral setup and our low-cost commutator represents a highly competitive and complementary addition to the recently emerging battery of open-source initiatives.