This thesis presents a closed-loop deep brain stimulation device with on-board artificial intelligence for measuring serotonin within the brain. The device has a miniature footprint and includes a neural sensor and stimulator. It enables discovery of neurochemical dynamics within the brain for the treatment of neurological and psychiatric disorders.<p></p>