A ventilation system, comprising: a ventilator connected to a patient circuit; a pressure transducer configured to determine a pressure in the patient circuit and to provide an electrical signal indicative of the pressure in the patient circuit; a valve which is connected to the patient circuit via a connection and which is configured to control the pressure in the ventilation system, the valve comprising: an electromagnet (105, 106), a shaft connected to the electromagnet (105, 106), and a diaphragm connected to the shaft; a controller which is connected to the valve and configured to receive the electrical signal from the pressure transducer; and a valve driver that is configured to receive commands of the controller and to provide a current to the electromagnet (105, 106) of the valve based on the commands of the controller, wherein the controller is configured to provide the commands to the valve driver based on the electrical signal, and wherein the electromagnet (105, 106) applies a force to the diaphragm based on the current provided by the valve driver, characterized in that the controller is configured to control the valve driver to control the electromagnet (105, 106): - to raise the diaphragm of the valve to allow air to be released to the ambient through an opening in the connection to the patient circuit if the pressure in the patient circuit is above a positive pressure threshold, and - to raise the diaphragm of the valve to allow air to be provided from the ambient through the opening in the connection if the pressure in the patient circuit is below a negative pressure threshold. a ventilator connected to a patient circuit; a pressure transducer configured to determine a pressure in the patient circuit and to provide an electrical signal indicative of the pressure in the patient circuit; a valve which is connected to the patient circuit via a connection and which is configured to control the pressure in the ventilation system, the valve comprising: an electromagnet (105, 106), a shaft connected to the electromagnet (105, 106), and a diaphragm connected to the shaft; a controller which is connected to the valve and configured to receive the electrical signal from the pressure transducer; and a valve driver that is configured to receive commands of the controller and to provide a current to the electromagnet (105, 106) of the valve based on the commands of the controller, wherein the controller is configured to provide the commands to the valve driver based on the electrical signal, and wherein the electromagnet (105, 106) applies a force to the diaphragm based on the current provided by the valve driver, characterized in that the controller is configured to control the valve driver to control the electromagnet (105, 106): - to raise the diaphragm of the valve to allow air to be released to the ambient through an opening in the connection to the patient circuit if the pressure in the patient circuit is above a positive pressure threshold, and - to raise the diaphragm of the valve to allow air to be provided from the ambient through the opening in the connection if the pressure in the patient circuit is below a negative pressure threshold. - to raise the diaphragm of the valve to allow air to be released to the ambient through an opening in the connection to the patient circuit if the pressure in the patient circuit is above a positive pressure threshold, and - to raise the diaphragm of the valve to allow air to be provided from the ambient through the opening in the connection if the pressure in the patient circuit is below a negative pressure threshold.