1// lowest and highest sensor readings:
2const int sensorMin = 0; // sensor minimum
3const int sensorMax = 1024; // sensor maximum
4
5void setup() {
6 // initialize serial communication @ 9600 baud:
7 Serial.begin(9600);
8}
9void loop() {
10 // read the sensor on analog A0:
11 int sensorReading = analogRead(A0);
12 // map the sensor range (four options):
13 // ex: 'long int map(long int, long int, long int, long int, long int)'
14 int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
15
16 // range value:
17 switch (range) {
18 case 0: // A fire closer than 1.5 feet away.
19 Serial.println("** Close Fire **");
20 break;
21 case 1: // A fire between 1-3 feet away.
22 Serial.println("** Distant Fire **");
23 break;
24 case 2: // No fire detected.
25 Serial.println("No Fire");
26 break;
27 }
28 delay(1); // delay between reads
29}
30