// Static Variables int smokeSensor = A0; // Smoke sensor pin int buzzer = 13; // Buzzer pin // Dynamic variables int smokeValue = 0; // Value read in by the smoke sensor void setup() { // Initiates the buzzer pin as OUTPUT pinMode(buzzer, OUTPUT); } void loop() { // Read the analogical value from the sensor and store it as % smokeValue = analogRead(smokeSensor); smokeValue = map(smokeValue,0,1023,0,100); // Short wait delay(50); // If the smoke level is too high, activate the alarm if (smokeValue > 60) { digitalWrite(buzzer, HIGH); } else { digitalWrite(buzzer, LOW); } }