Devices & Components
Arduino Uno Rev3
Resistor 220 ohm
5 mm LED: Green
Buzzer, Piezo
Jumper wires (generic)
Gas Sensor
Breadboard (generic)
5 mm LED: Red
Software & Tools
Arduino IDE
Tinkercad
Project description
Code
Code for smoke Detector
arduino
1int red_LED_PIN = 11; 2int green_LED_PIN = 9; 3int blue_LED_PIN = 10; 4int buzzer = 6; 5int smoke_detector = A0; 6int safety_lim = 60; //Sets smoke density safe limit 7 8void setup() { 9 pinMode(red_LED_PIN, OUTPUT); 10 pinMode(green_LED_PIN, OUTPUT); 11 pinMode(blue_LED_PIN, OUTPUT); 12 pinMode(buzzer, OUTPUT); 13 pinMode(smoke_detector, INPUT); 14 Serial.begin(9600); //baud rate 15} 16 17void loop() { 18 int sensor_read = analogRead(smoke_detector); 19 //reads and stores the reading from the detector in sensor_read 20 21 Serial.print("Smoke Density: "); 22 Serial.println(sensor_read); 23 24 if (sensor_read > safety_lim) 25 // Checks if reading is beyond safety limit 26 { 27 analogWrite(red_LED_PIN,255); 28 analogWrite(green_LED_PIN, 0); 29 tone(buzzer,500, 100); //piezo rings 30 } 31 else 32 { 33 analogWrite(green_LED_PIN, 255); 34 analogWrite(red_LED_PIN,0); 35 noTone(buzzer); //peizo wont ring 36 } 37 delay(50); 38}
Downloadable files
Schematic of Smoke Detector
Schematic of Smoke Detector

Schematic of Smoke Detector
Schematic of Smoke Detector

Comments
Only logged in users can leave comments