A method and apparatus for operating a ventilator to control the fraction ofpressure inspired oxygen (FiO2) to a patient that includes: providing aventilator controller that includes a software algorithm, a pulse oximeter anda (FiO2) flow rate controller; measuring the pulse oximetry of the patient andcomputing an average pulse oximetry value over a time period; selecting afirst, second and third pulse oximetry levels as set points for the ventilatorcontroller; selecting an update time interval; decreasing the (FiO2) flow rateby a first incremental amount when the average pulse oximetry value is greaterthan the first level; increasing the (FiO2) flow rate by a second incrementalamount when the average pulse oximetry value is less than the second level;increasing the (FiO2) flow rate to the maximum and initiating an alarmcondition when the average pulse oximetry value is less than the third level.