This protocol demonstrates how to use an electrophysiological system for closed-loop stimulation triggered by neuronal activity patterns. Sample Matlab code that can be easily modified for different stimulation devices is also provided.