Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. How do I turn a Pin to HIGH from controller?

How do I turn a Pin to HIGH from controller?

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 3 Posters 874 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • fetsF Offline
      fetsF Offline
      fets
      wrote on last edited by
      #2

      @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

      1 Reply Last reply
      0
      • nielsokkerN Offline
        nielsokkerN Offline
        nielsokker
        wrote on last edited by
        #3

        There is an example that exactly gives you what you need. The Relay example is the structure of what you need to use.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        32

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular