Skip to content

Commit 506d235

Browse files
mfalkviddhenrikekblad
authored andcommitted
Update RelayActuator example (#973)
Based on feedback from skywatch, https://forum.mysensors.org/post/78896 We'll need to update the wiring instructions on https://www.mysensors.org/build/relay as well.
1 parent 1e33059 commit 506d235

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/RelayActuator/RelayActuator.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141

4242
#include <MySensors.h>
4343

44-
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
44+
#define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
4545
#define NUMBER_OF_RELAYS 1 // Total number of attached relays
4646
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
4747
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
4848

4949

5050
void before()
5151
{
52-
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
52+
for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
5353
// Then set relay pins in output mode
5454
pinMode(pin, OUTPUT);
5555
// Set relay to last known state (using eeprom storage)
@@ -67,7 +67,7 @@ void presentation()
6767
// Send the sketch version information to the gateway and Controller
6868
sendSketchInfo("Relay", "1.0");
6969

70-
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
70+
for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
7171
// Register all sensors to gw (they will be created as child devices)
7272
present(sensor, S_BINARY);
7373
}
@@ -84,7 +84,7 @@ void receive(const MyMessage &message)
8484
// We only expect one type of message from controller. But we better check anyway.
8585
if (message.type==V_STATUS) {
8686
// Change relay state
87-
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
87+
digitalWrite(message.sensor-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
8888
// Store state in eeprom
8989
saveState(message.sensor, message.getBool());
9090
// Write some debug info

0 commit comments

Comments
 (0)