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.


Log in to reply
 

Suggested Topics

42
Online

11.4k
Users

11.1k
Topics

112.6k
Posts