two sensors in arduino

: smiley-confuse:

I have a mega arduino, and two motion sensors (Motion sensor module HC-SR501) and one sound sensor (Sound sensor module with microphone KY-038), I need that when both are capturing arduino have a high output, and that When both are not sensing one or the other and not, have a low output but I do not know how to program it.

I am new to this forum and with Arduino, I would really appreciate it if you could help me

Start with only one sensor.
Read the sensor into a variable. Use an if statement to see if that variable is above some threshold value.
Then do the appropriate action of setting a pin high or low.
Do the same for the other sensor

Now you have both working you can combine them. Note you can use a compound if statement that combines the results of two comparisons using the logical AND operator that has the symbol &&

thanks, I’ll start with there, if the signals of the sensors that I am introducing to the arduino, are timed with an integrated circuit 555. when joining them in arduino they will not be affected, right?

I do not understand what a timed sensor input is.

Withholding information is the best way of getting people cross here.

Well, excuse me, really. I do not speak English.

I explain.

I try to make an energy optimizer in the with the aforementioned sensors I will capture or if there are people in the room or not, if not, the focus, in my case led, will be turned off; but, if there are people, the sensors will capture it and nothing will go out.

the timer, comes if it is day or night since if it is daytime he wanted the LED to take less time to turn off compared to yes is at night.

then I was going to temporize with an integrated circuit before joining the signals in arduino and I wanted to know if that could also be done?

kathVasquez:
Well, excuse me, really. I do not speak English.

Is that why you have an copy of this topic in the Spanish section of the forum?

AWOL:
Is that why you have an copy of this topic in the Spanish section of the forum?

yes

then I was going to temporize with an integrated circuit before joining the signals in arduino

As I said, I have no idea what you mean by that. You need to use better words.

Place the sensor in an electronic circuit where the timer will reduce or increase the time it delays the pulse that will enter Arduino.

Will Arduino have any problem with their input signals already going with their determined oscillation?

this is the 555 timer I'm talking about:

Ok thanks for clarifying that but why on Earth do you want to do that? Yes it will cause a problem so what advantage does it give you?

The Arduino will have no problem with it.
What that 555 is doing the Arduino can do very well by itself, and probably better. In other words: just get rid of it. Read the input pulse with the Arduino, and have the Arduino control your LEDs based on it. On, off, delayed based on time of the day, whatever - that's what processors like Arduinos are good at.
If all you want is a light that goes on for a set period of time upon detection of a sound, the 555 is a great, simple solution. The moment you want to do more (based on time of the day etc) you better just do it all with an Arduino.

thank you !, then I will try to do it and if something strange happens and I can not find the solution I will ask them, to see if they have the answer, I really thank you!

Hi,
I think the OP is using the 555 as a pulse extender to make sure that what ever duration pulse comes from the sensors the Arduino will get a decent square readable pulse input.

Tom... :slight_smile:
PS, just saw previous post, posted while writing this.

If the pulse is too short to detect by polling it's always possible to use interrupts. That way you shouldn't miss any such pulse.

Pulse stretching is NOT the same thing as delaying a signal which is what the OP said he was doing.
He said

Will Arduino have any problem with their input signals already going with their determined oscillation?

He should not be posting in the English section with such a poor grasp of the language and inability to communicate.

I thought at first indeed OP wanted to delay the pulse - now I don't know if this would really delay the pulse, other than having the Arduino to look for the second edge, rather than just a signal change. That's going to at least as complex, if not more, than reading the pulse as it happens, and then programming a delay in the Arduino, and with less control of the delay to boot.