ARDUINO SKETCH FOR FIRE SENSOR
////USE THIS CODE FOR FIRE SENSOR FOR BETTER RESULTS......
int val ;// define numeric variables val
float sensor; //read analoog value
void flamesensor()
{
int sensorReading = analogRead(A5);
// map the sensor range (four options):
// ex: 'long int map(long int, long int, long int, long int, long int)'
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// range value:
switch (range) {
case 0: // A fire closer than 1.5 feet away.
Serial.println("** Close Fire **");
Serial.println(sensorReading);
break;
case 1: // A fire between 1-3 feet away.
Serial.println("** Distant Fire **");
Serial.println(sensorReading);
break;
case 2: // No fire detected.
Serial.println("No Fire");
Serial.println(sensorReading);
break;
}
delay(5000); // delay between reads
}
int val ;// define numeric variables val
float sensor; //read analoog value
void flamesensor()
{
int sensorReading = analogRead(A5);
// map the sensor range (four options):
// ex: 'long int map(long int, long int, long int, long int, long int)'
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// range value:
switch (range) {
case 0: // A fire closer than 1.5 feet away.
Serial.println("** Close Fire **");
Serial.println(sensorReading);
break;
case 1: // A fire between 1-3 feet away.
Serial.println("** Distant Fire **");
Serial.println(sensorReading);
break;
case 2: // No fire detected.
Serial.println("No Fire");
Serial.println(sensorReading);
break;
}
delay(5000); // delay between reads
}
Comments
Post a Comment