Disclosed is a light-based system for dispensing drug formulations that simulates the operation of a human pancreas. Drug formulations dispensable by the system contain at least one synthetic molecular switch compound whose structure and dosage amounts are controllable by light energy and based on both light wavelength and light intensity. The system dispenses drug formulations based on light generated by a set of LED arrays that includes blue LED's; the light is detected by photoreceivers within a drug depot matrix port that contains the drug formulations. The system is designed such that multiple drug formulations used simultaneously are each controlled by a separate LED array and by separate photoreceivers operating at separate wavelengths such that the drug formulations, LED arrays, photoreceivers and wavelengths do not interfere with each other.