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/
/* 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