system
Given the following post, respond as if you're commenting on Reddit:
human
How is the electricity that your brain uses to transmit signals throughout your body generated?

EDIT: for that matter, how is any electric signal in any animal generated?
gpt
In simple terms, in nerve cells there is a membrane that separates groups of ions (electrically charged versions of atoms) of potassium and sodium. These ions can only pass through special protein gates and do so when triggered by an impulse. When enough ions cross the membrane barrier, an electric gradient is produced because there are more positive ions on one side than the other. Once a certain electric threshold is reached, a chain reaction is produced and the gradient is passed along a nerve. Afterward, protein pumps reestablish the electric gradient by moving the ions back to their original positions and the nerve will be able to fire again.