const int flameSens = A0;//set flame sensor to pin A0
const int buzzer = 8;//set speaker to pin 8
int flameVal;//set up the data variable for the sensor
void setup(){
Serial.begin(9600);//begin the serial monitor
pinMode(buzzer, OUTPUT);//define the speaker as an output
pinMode(flameSens, INPUT);//define flame sensor as an input
}
void loop() {
int flameVal = analogRead(flameSens);//read the sensor value of flame sensor
if (flameVal < 1023){//if the data us less than 1023 then set off an alarm
digitalWrite(buzzer, HIGH);
}
else{
digitalWrite(buzzer, LOW);// if else don't set off alarm
}
Serial.println(flameVal);//print the data to the serial monitor
}
Fire alarm
Less cost and mas use fire alarm
Comments