keskiviikko 6. helmikuuta 2013

Arduino Flame Detection Sensor Module

Our home task was to find out what the sensor does. I got flame detection sensor module which detects infrared rays. We connected one led to the sensor, so it would set on if the sensor detects infrared. We had a remote control which of course works with infrared. Always when we pushed a button the led turned on. It worked pretty well.






The code:

/*SENSOR PINOUT:

PIN 1: Analogue out
PIN 2: Ground
PIN 3: +5V
PIN 4: Digital out

You may copy, alter and reuse this code in any way you like but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.

Modified by Niki Ahlskog & Anders Borgström */


/* Select the input pin for the flame detectors analogue output. */
#define FLAME_DETECT_ANA A0

/* Select the input pin for the flame detectors digital output. */
#define FLAME_DETC_DIO 2
int led = 8;


/* Initialise serial and DIO */
void setup()
{
/* Setup the serial port for displaying the status of the sensor */
Serial.begin(9600);
pinMode(led, OUTPUT);
/* Configure the DIO pin the sensors digital output will be connected to */
pinMode(FLAME_DETC_DIO, INPUT);
}


/* Main program loop */
void loop()
{
/* Read the sensors analogue output and send it to the serial port */
Serial.print("Sensor Value: ");
Serial.print(analogRead(FLAME_DETECT_ANA));

/* Read the status of the sensors digital output and if it is high
then send an alert to the UART */
if (digitalRead(FLAME_DETC_DIO))
{
Serial.println(" FLAME DETECTED!");
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);

}else
{
Serial.println();
digitalWrite(led, LOW);

}

}

The sensor: http://dx.com/
Original code: http://www.hobbycomponents.com/



Ei kommentteja:

Lähetä kommentti