And the Chinese researchers say the approach could pave the way for a "new era" in medicine.
The first step was to turn normal cells into living factories.
They were genetically engineered to manufacture drugs that control blood sugar levels such as insulin - but only in response to light.
The technology is called optogenetics and these cells would kick into gear when exposed to specific wavelengths of red light.
Then comes the tech - a set of wirelessly powered LEDs and a smartphone app to control them.
Researchers at East China Normal University in Shanghai implanted the system into mice and were able to control diabetes with the tap of a touchscreen.
J SHAO-The device was implanted under the skin
The team said the findings "could pave the way for a new era of personalised, digitalised and globalised precision medicine".
The scientists needed to take tiny drops of blood to know how high the blood sugar levels were so they could calculate how much drug to release inside the animal.
Their ultimate goal is a fully automated system that both detects sugar levels and then releases the right amount of therapeutic chemicals.
This idea is clearly at an early stage, but it is not limited to diabetes. Cells could be engineered to manufacture a wide range of drugs.
Prof Mark Gomelsky, a molecular biologist from the University of Wyoming, said the study was an "exciting accomplishment".
He added: "How soon should we expect to see people on the street wearing fashionable LED wristbands that irradiate implanted cells engineered to produce genetically encoded drugs under the control of a smartphone?
"Not just yet, but the work provides us with an exciting glimpse into the future of smart cell-based therapeutics."