Characteristic abnormal carbon dioxide waveforms from patients with mechanically ventilated lungs are observed when, for example, valves are incompetent, the airway is obstructed, the breathing circuit becomes disconnected, or a patient overrides mechanical ventilation with spontaneous breaths. Automated observation of the carbon dioxide waveform provides a uniform, concise, and consistent interpretation of the capnogram. This article describes a computer algorithm for analyzing and classifying capnograms as normal or as belonging to one of the categories above. The algorithm also generates a diagnostic message when the capnogram deviates from a learned norm for at least three consecutive waveforms (and thus reduces the influence of artifacts). Clinical experience shows reliable waveform recognition by the algorithm.