The control of where and when bacteria adhere to a substrate is a key step toward controlling the formation and organization in biofilms. This study shows how we engineer bacteria to adhere specifically to substrates with high spatial and temporal control under blue light, but not in the dark, by using photoswitchable interaction between nMag and pMag proteins. For this, we express pMag proteins on the surface of E. coli so that the bacteria can adhere to substrates with immobilized nMag protein under blue light. These adhesions are reversible in the dark and can be repeatedly turned on and off. Further, the number of bacteria that can adhere to the substrate as well as the attachment and detachment dynamics are adjustable by using different point mutants of pMag and altering light intensity. Overall, the blue light switchable bacteria adhesions offer reversible, tunable and bioorthogonal control with exceptional spatial and temporal resolution. This enables us to pattern bacteria on substrates with great flexibility.