This Arduino code defines a buzzer and smoke sensor connected to pins D2 and A0. In setup, the pins are configured as output and input. In loop, the smoke sensor value is read and printed, and if above a threshold of 600, a 1000Hz tone is sounded on the buzzer for 200ms, otherwise the buzzer is silent. This provides a simple smoke detector that uses a sensor to trigger an alarm buzzer when smoke is detected.
This Arduino code defines a buzzer and smoke sensor connected to pins D2 and A0. In setup, the pins are configured as output and input. In loop, the smoke sensor value is read and printed, and if above a threshold of 600, a 1000Hz tone is sounded on the buzzer for 200ms, otherwise the buzzer is silent. This provides a simple smoke detector that uses a sensor to trigger an alarm buzzer when smoke is detected.
This Arduino code defines a buzzer and smoke sensor connected to pins D2 and A0. In setup, the pins are configured as output and input. In loop, the smoke sensor value is read and printed, and if above a threshold of 600, a 1000Hz tone is sounded on the buzzer for 200ms, otherwise the buzzer is silent. This provides a simple smoke detector that uses a sensor to trigger an alarm buzzer when smoke is detected.
void loop() { int analogSensor = analogRead(smokeA0);
Serial.print("Pin A0: ");
Serial.println(analogSensor); // Checks if it has reached the threshold value if (analogSensor > sensorThres) { tone(buzzer, 1000, 200); } else { noTone(buzzer); } delay(100); }