Disclosed is a light-based artificial pancreas system for dispensing drug formulations to a diabetic patient that monitors the status of the patient to ensure that blood glucose levels remain within a customizable range. Drug formulations dispensable by the system contain at least one photoswitchable compound, including insulin, whose 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 or violet LED's; the light is detected by photoreceivers within a drug reservoir 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.