How to keep relay activated when 2 inputs are HIGH

How to keep an output (in my case relay) HIGH when two inputs (one IR sensor AND one switch) are HIGH?? The output should remain HIGH as long as both inputs are HIGH. Using a delay is not possible in this case because the arduino is doing other stuff aswell.

This is the part of my sketch but the relay is only very briefly activated..

if (sensorState0 == HIGH && valA4 == HIGH) {
digitalWrite(relay0, HIGH);

Any suggestions?

rgrds,

Without seeing the code, I can still be quite sure you must be writing LOW to that pin somewhere else.

Digital outputs are known for putting out the logic level last written to them.

So, more code, please, all of it ideally, or a shortened version that demonstrates this behaviour.

a7

1 Like

@leoarduinofiddler Time for you to refer to the canonical

or, ...we can't fix what we can't see.

1 Like

What does line 7 say in the book on my lap? You can answer that about as easy as we can answer your question. Post your code using code tags, If you read the link camsysca has posted you will understand what to do.

1 Like

I know! I know!

methodically knocking people’s hats off- then, I account it high time to get to sea as soon as I can. This is my substitute

a7

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.