We have been investigating DNA state machines, especially those based on the opening of hairpin molecules in which state transitions are realized as hairpin loops are opened by molecules called openers. This paper introduces photo- and thermoregulation of such hairpin-based DNA machines, in which the openers become active by sensing external signals in the form of light or heat. We conducted fluorescence experiments and show that photo- and thermoregulation is possible. In the experiments, the openers become active when they are irradiated by UV light or when they receive heat as external input. For photoregulation, we use azobenzene-bearing oligonucleotides developed by the third author.