Breathing, the basis of the functions of the respiratory system, is actually a complex physiologic act with an inspiratory component as well as an expiratory component.
Spontaneous (involuntary) inspiration starts when the respiratory center in the medulla oblongata emits neural signals, which travel along the central and peripheral nervous system to the inspiratory muscles (in particular, the diaphragm) causing them to contract. These signals can also be influenced by impulses that arise in the pons.
Both inspiration and expiration can be controlled voluntarily by impulses from the cerebral cortex. The inspiratory muscle contractions allow the flexible bellows (the chest wall) to expand thereby lowering the intrathoracic pressure in the respiratory system air conduits to less than atmospheric pressure. As we know from the principles of physics, air flows into the place where pressure is lower and thus moves down into the alveoli where carbon dioxide and oxygen are exchanged and respiration is completed.
The respiratory center is affected by various stimuli, the most important being the pH of the cerebrospinal fluid bathing that area of the brain. This pH is primarily due to carbon dioxide (CO2) which is freely diffusible throughout the tissues of the body. Low oxygen (O2) can have a similar stimulatory effect on the respiratory center.
The respiratory center can also be affected by the effect of O2 and CO2 on the carotid and aortic bodies as well as by stretch receptors in the smooth muscles of the airways, irritant receptors between the epithelial cells in the airway, joint and muscle receptors, and juxtacapillary (or J) receptors in the alveolar walls.
Expiration during spontaneous breathing is a passive process. Once the inspiratory center ceases to fire, the inspiratory muscles cease to contract, and the elastic recoil of the lungs and chest wall causes the pressure in the airways to rise above atmospheric pressure. The result is movement of the airway gases to the outside of the body. Expiration can also be active via impulses from the cerebral cortex.
The functions of inspiration and expiration are still areas of active research and as in all research the concepts described above may change.