Simply put, pills are stupid. They don’t know what’s going on in your body when you take them, they don’t know the optimal time to release their medication, and they certainly can’t vary their own dosage levels on the fly. But thanks to the blinking E. coli created by researchers at the University of California, San Diego, that’s all about to change.

The UCSD researchers have created a mechanism for cyclical gene expression in bacteria that can then be propagated throughout an entire bacterial colony like a wave. In the video above, the bacteria are reading the gene for a fluorescent dye. A genetic circuit with a built-in time delay keeps the blinking at a regular rate, and inter-bacterium communication synchronizes the blinking.

But swap out the dye gene for one that makes drugs, and all of a sudden you get a yogurt that releases exact medication dosages from within one’s own body based on real time feedback.

To synchronize the bacteria, the researchers co-opted a phenomena called quorum sensing. In quorum sensing, bacteria exchange small molecules to other cells in the colony to help regulate colony conditions.

By tweaking the triggers and feedback loops used by E. coli in its quorum sensing protocol, the UCSD scientists created a clock-like circuit. They then linked transcription of the fluorescent protein gene to ticks of the bacterial clock to create the waves seen in the video. By adjusting the pH, temperature, and other environmental factors, scientists can engineer the bacteria to react in unison at any interval of timing desired.

The final goal of this project is to create bacteria that respond to a wide range of stimuli by producing a man-made compound, like a drug.

Imagine bacteria that responded to specific bodily changes by releasing insulin, then a diabetic would only need to eat a yogurt of the bacteria with every meal and the medicinal bacteria would take care of the rest. Similarly, scientists could create bacteria that responded to toxins by glowing. Coat a surface with these benign bacteria, and you would have an instant, cheap, and persistent pollution sensor.

If pills want to stay in the game with these bugs around, they’re gonna need to smarten up, and fast.