How do I turn a Pin to HIGH from controller?
-
I thought it would be really easy but I can't understand how to do this simple task. I have a Led connected so if Pin 9 = High it turns on.
But how can I write the sketch so that I can control the Led from my controller (domoticz) ?
I have started with this by modifying the motion-sketch:
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define LIGHT_PIN 9 #define CHILD_ID 1 // Id of the sensor child #define SECONDARY_CHILD_ID 4 // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); MyMessage msg2(SECONDARY_CHILD_ID, V_LIGHT); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input pinMode(LIGHT_PIN, OUTPUT); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor ikea", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); present(SECONDARY_CHILD_ID, S_LIGHT); } }
But nothing happens when I press the on/off switch that appears in domoticz witch kind of makes sense as I guess I need to add something in the loop. But how do do that? Are there some kind of " if [message-from-controller] then do this - command?
And why does not the PIR show up in domoticz? I have only added a few lines, does that disable the original PIR code in someway.
-
@Cliff-Karlsson you need to manage incoming message from gateway/controller : (function void receive(const MyMessage &message) { ...}) and to chage pin state according message .
See this example.And why does not the PIR show up in domoticz?
I thing that domoticz needs at least 1 data message to show device
-
There is an example that exactly gives you what you need. The Relay example is the structure of what you need to use.
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
NODs stop responding, but ping works.
Troubleshooting • about 14 hours ago • Marcin about 14 hours ago -
Forum Search not working?
Troubleshooting • 4 Oct 2023, 23:33 • Gibber 2 Sept 2024, 20:28 -
Some sensors permanently fail after one/two years
Troubleshooting • 25 Jul 2024, 17:17 • Kokosnoot 25 Jul 2024, 17:17 -
Getting system time from the controller
Troubleshooting • 10 days ago • dpcons 6 days ago -
Can not compile MySensors on esp8266
Troubleshooting • 24 Aug 2024, 15:35 • TheoL 29 Aug 2024, 20:47