When your cells burn food for energy, they end up with carbon dioxide as a waste product. Your lungs ultimately take care of that waste by expelling it from your system. But carbon dioxide is more than just waste; CO2 concentrations in your bloodstream play a critical role in maintaining a stable pH and in helping your body figure out how often you need to breathe.
When you add a drop of food coloring to a glass of water, the color gradually spreads throughout the water as dye molecules seep from a zone of high concentration to zones of low concentration. This natural tendency for molecules to spread out of a region where they are concentrated into a region where they are not is called diffusion. Inside your body, carbon dioxide is produced by cells in your tissues, so blood traveling back to your lungs is rich in CO2. That's why CO2 diffuses out of your blood and into your lungs -- the concentration of CO2 in the blood is higher than the concentration of CO2 in the air you've just inhaled.
Your body has to keep the CO2 concentration in your lungs low so that CO2 will diffuse out of your blood into your lungs and not the other way around. In order to do that, you have to breathe out or exhale. How often you have to exhale depends on how much CO2 your tissues are producing; you need to exhale much more often if you're sprinting than if you're lying asleep in bed, for example. The region of your brain called the medulla regulates the rate of your breathing without any need for conscious thought on your part. It responds to a variety of factors, but one of the most important is the concentration of CO2 in your blood.
Carbon dioxide dissolved in water can react with the water to form carbonic acid. In your blood, this reaction is catalyzed or sped up by an enzyme called carbonic anhydrase so it happens very rapidly. The carbonic acid can in turn give up a hydrogen ion to become bicarbonate. Most of the carbon dioxide in your blood is found in the form of bicarbonate. The result is that an increase in CO2 concentrations will slightly decrease the pH of your blood or make it very slightly more acidic, while a decrease in CO2 concentrations will make it very slightly less acidic. Receptors on nerve cells that communicate with the medulla can sense the very slight change in pH associated with this activity -- and your medulla can help use that information to figure out when you need to breathe.
Another molecule that plays a critical role in CO2 regulation is hemoglobin, the same protein that transports oxygen in your blood. Hemoglobin can pick up some of the extra hydrogen ions released by carbonic acid; once it's unloaded its oxygen cargo, hemoglobin can also pick up and help transport some of the CO2 as well. Thanks to hemoglobin and carbonic anhydrase, only about 10 percent of the carbon dioxide in your blood is actually present in the form of dissolved carbon dioxide. All these components working together help to keep carbon dioxide concentrations stable and remove this gas from your system.