Go Down

### Topic: How to Create logic (Read 2886 times)previous topic - next topic

#### PeterH

#15
##### May 06, 2013, 04:31 pm
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