Sunday, September 8, 2013

Building a IR Fire Sensor

This second sensor project uses the IR Fire Sensor. It has two outputs, 1 digital, 1 analog. I'm using the digital output (sensitivity set with onboard trimmer pot) to set the Pin 13 LED, to show flicker. I'm dumping the raw analog output to the serial monitor. Increased IR levels decrease the values output to the serial monitor.

Sensor Kit
Male to Female Jumper Kit






const int analogPin =  A0;      // the number of the analog pin
const int digitalPin = 7;     // the number of the digital pin
const int ledPin =  13;      // the number of the LED pin
int aVal = 0;
int dVal = 0;

void setup() {

  Serial.begin(9600);          //  setup serial

  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);    
  // initialize the digital pin as an input:
  pinMode(digitalPin, INPUT);  
}

void loop(){


  aVal = analogRead(analogPin);    // read the input pin
  Serial.println(aVal);             // analog value

  dVal = digitalRead(digitalPin);   // read the input pin
  digitalWrite(ledPin, dVal);    // sets the LED to the digital sensor's value
}