Hi guys i’m trying to have multiple sensor connected to arduino. I have tried by using the guide from (http://arduinotronics.blogspot.sg/2012/ … orial.html ) and it works well with my gas sensor. Now i am trying to add on a motion sensor and a dry contact. The output will have 3 led each connected to individual sensor to sense if the sensor detect anything. Thank you!
hi Mee_n_Mac! You are everywhere! The code in the link works for 1 sensor (gas sensor). How do i modify the code to such that it can do it with multiple sensor. From what i understand from the code is that i need to change the value of
(sensorValue >= 750) for different sensor then the specific output led pin will be high and light up.
You add more code. Depending on the sensor that might be another analogRead() on a different pin or a digitalRead() on a different pin or … some other input channels that you need not be concerned with ATM. If I understand your intent, you’d read each sensor in turn and set it’s LEDs (on differing output pins) accordingly. The dry contact is a switch and so you read it like any switch. The PIR has a switch-like output (open/close to ground) and so, w/a pullup resistor, it too is read like a switch. Read the tutorial and envision reading 2 switches (sensorVal1, sensorVal2), one right after the other. Then add in your existing code.