1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* Relay Shield - Blink
* Turns on the relay for two seconds, then off for two seconds, repeatedly.
*
* Relay Shield transistor closes relay when D1 is HIGH
*/
const
int
relayPin
=
D1
;
const
long
interval
=
2000
;
// pause for two seconds
void
setup
()
{
pinMode
(
relayPin
,
OUTPUT
);
}
void
loop
()
{
digitalWrite
(
relayPin
,
HIGH
);
// turn on relay with voltage HIGH
delay
(
interval
);
// pause
digitalWrite
(
relayPin
,
LOW
);
// turn off relay with voltage LOW
delay
(
interval
);
// pause
}
The relay blink sample will turn on and off the relay every two seconds. Since the DHT Pro shield uses D4
pin and the Relay shield uses D1 pin both can be used at the same time. I had no problem uploading the
sample to the board, and hearing the relay switch on and off every 2 second.