
5
4. Usage
The module is mainly used to detect the infrared light. It outputs digital signal 0 and 1 through a
Comparator output. The output value will be 0 when infrared light is detected. And the sensitivity
is adjustable by the precision potentiometer.
Let's use it to control. When the output value is 0, the led will light up.
1. Connect the module to the D3 of
2. Plug the Grove - Base Shield into Arduino.
3. Connect Arduino to PC by using a USB cable.
4. Copy and paste code below to a new Arduino sketch. Please click here if you do not know how
to upload.
/************************************************************************
******/
#define SENSOR 3
//connect SENSOR to digital pin3
#define LED 2
//connect Grove - LED to pin2
void
setup
()
{
pinsInit
();
}
void
loop
()
{
if
(
isFlameDetected
())
turnOnLED
();
else
turnOffLED
();
}
/********************************/
void
pinsInit
()
{
pinMode
(
FLAME_SENSOR
,
INPUT
);
pinMode
(
LED
,
OUTPUT
);
digitalWrite
(
LED
,
LOW
);
}
void
turnOnLED
()
{
digitalWrite
(
LED
,
HIGH
);
}
void
turnOffLED
()
{