Hana El-Samad is a bit of a control freak. She’s been obsessed with the idea of injecting order into chaos since she was a little girl growing up in Lebanon during the height of the country’s protracted civil war. During the day, El-Samad would bury herself in the textbooks her mother, a math teacher, brought home—the unfailing law and order of numbers and equations her cloak against the uncertainty outside.

When she got to college, that predilection turned to a career. That’s when she found a field called feedback control theory—the study of how complex systems regulate themselves. “Everything just came into focus,” says El-Samad, now a systems biologist at UC San Francisco. “There is a system of checks and balances that make sure the craziest of us are put back in line, and that’s true in human societies, in ecosystems, and inside organisms. Sometimes those systems fail. And you get war. Or disease.”

She started building robots, designing feedback control algorithms to stabilize their movements. A few years later, as a PhD student in Ames, Iowa, she worked on automated flight control systems for Rockwell Collins, a US military aerospace contractor. But El-Samad worried that her work would wind up in war zones like the one she had grown up in. That’s when she switched to designing circuits for living cells instead.

She wasn’t alone. In the early 2000s, lots of electrical engineers and control theorists were joining the emerging field of synthetic biology, thinking they could design biological circuits to control the flow of information in a cell, just as the physical versions moved electrons around computer chips. They started designing strings of DNA never seen before in nature, and sticking these synthetic operating systems into bacteria and yeast. But these tools remained blunt. Sure, you could make a malaria-drug-belching E. coli, but you couldn’t tell it to stop making the medicine when there was too much, or to just make a certain amount every day at the same time. For that, you needed feedback control.

"There is a system of checks and balances that make sure the craziest of us are put back in line. That’s true in human societies, in ecosystems, and inside organisms." -Hana El-Samad, UC San Francisco

And that’s where El-Samad comes in—along with the ideas of a Russian-American engineer named Nicolas Minorsky. Every time you flick on your car’s calf-saving cruise control or bask in your Nest-enabled, cool but not cold home, you can thank Minorsky. In the 1920s, his penchant for calculus combined with patient observations of helmsmen steering US battleships allowed Minorisky to figure out the mathematical theory behind proportional-integral-derivative control, or PID. Today, PID algorithms are everywhere in the modern world; they run aircraft autopilot programs, keep manufacturing robots from crushing their human coworkers, and make smart thermostats, well, smart.

This week, El-Samad and a team of collaborators from David Baker's lab at the University of Washington announced that they had figured out how to make a biological equivalent of a PID algorithm. It starts with a designer protein—they call it LOCKR, short for Latching Orthogonal Cage Key pRoteins. Shaped like a cage with a latched door on one side, the LOCKR opens wide when it comes into contact with a preset molecule, revealing whatever functions researchers have hidden inside the cage.

For example, in one version, that function is a tag that condemns whatever is attached to it to a cellular garbage heap. Say you’ve got an enzyme that takes molecule A and breaks it down into molecules B and C. But you’re worried you’re going to wind up with too much of molecule C, which can be toxic. You design a LOCKR whose key is molecule C, and you fuse it to molecule A. As the enzyme makes more and more molecule C, it opens more of these LOCKR proteins, revealing a tag to send it, along with molecule A to the garbage dump. Without molecule A, the enzyme slows down its production of molecules B and C. And that, my friends, is a feedback control circuit.

Network a few LOCKR-bound molecules together, and you’ve got a circuit that can control a cell’s functions the same way a PID computer program automatically adjusts the pitch of a plane. With the right key, you can make cells glow or blow themselves apart. You can send things to the cell’s trash heap or zoom them to another cellular zip code. That’s what the scientists showed LOCKR could do in yeast. Their long-term goal is to use LOCKR and other small, synthetic molecules to program human cells to steer themselves to diseased tissues, including the hard-to-reach brain, and reliably drop off a precise payload of drugs.

Megan Molteni covers DNA technologies, medicine, and genetic privacy for WIRED.

Other synthetic biology pioneers were impressed with the advance. “This technology is quite cool,” says Tim Lu, a computational biologist at MIT and cofounder of Synlogic, a company that is reprogramming bacteria to fight cancer. It has the potential to offer faster feedback control than other approaches, he says. But there’s still a lot of work to do before you could start thinking about putting LOCKR into people: “One of the key things that needs to be evaluated going forward is potential immunogenicity.”