Go Down

Topic: How to Create logic (Read 1 time) previous topic - next topic

PeterH

Your diagram shows that you have got pull-down resistors in place so you do not have floating inputs. (I assume these resistors are in place for all four inputs used by your sketch.)

I think the problem is that these conditions are not all mutually exclusive:

Code: [Select]

if (P1State == HIGH)
if (L2State == HIGH)
if (L1State ==HIGH)
if (L2State ==HIGH && P1State==HIGH)


This means that even if you correctly turn the outputs off in one piece of code, they could be turned on again by another piece of code.

I suggest you restructure so that they are mutually exclusive and the precedence between them is defined explicitly, e.g.:

Code: [Select]

if (L2State == HIGH && P1State == HIGH)
{
}
else
{
   if (P1State == HIGH)
   {
   }
   if (L2State == HIGH)
   {
   }
}
if (L1State == HIGH)
{
}

I only provide help via the forum - please do not contact me for private consultancy.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy