Two motion sensors on one Arduino. How?
-
Hey,
pin 2 and 3 can get interrupt on Arduino. Pin 2 is used for radio already. So only one pin left.
I am so much of a noob that i can't tell if there is a solution for that problem?
Anybody knows how to get two motion sensors running on one Arduino?That would safe me money, time and space :)
Thx
ED -
Hi.
Yes you can use multiple interrupts. two ways:
- http://www.gammon.com.au/forum/?id=11091 . So you can use multiple input on one of your interrupt pin (INT0 or INT1)
- I'm using this one to save diodes footprint on one of my board : http://gammon.com.au/forum/?id=11488&reply=6#reply6
But it's less easy in sketch if you're noob
-
Hey,
pin 2 and 3 can get interrupt on Arduino. Pin 2 is used for radio already. So only one pin left.
I am so much of a noob that i can't tell if there is a solution for that problem?
Anybody knows how to get two motion sensors running on one Arduino?That would safe me money, time and space :)
Thx
ED@edsteve - Pin2 isnt used by the nrf24l01 what I know. (Atleast not prior to 2.0) You can use this pin as well for interrupt.
-
Huff. I am too nooobish in programming :(
Can anyone tell me how to change the example code to get a second motion sensor on pin2 working with Domoticz?Here the example:
// Enable debug prints // #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); } void loop() { // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); } -
Huff. I am too nooobish in programming :(
Can anyone tell me how to change the example code to get a second motion sensor on pin2 working with Domoticz?Here the example:
// Enable debug prints // #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); } void loop() { // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login