# Some logic decision question

Hello everyone,

I am working on a project, I got some part of the project working, but I am stuck on something.

Let's say :

A = 73
B = 70

If A is greater than B,
turn pin on
else
turn it off (So here B = A)

I got the above part working fine, no problems.

My problem is here:

Now, I want B to be 3 less than A or 70, until this true, start all over again.
Nothing will happen if B is 73, or 72, or 71, until B is 70 then the pin will be turned on again.

I tried some for loops, no luck. How can I accomplish this?

if ((A - B) >= 3) { do your thing }

ITAlex:
I want B to be 3 less than A or 70

Try and rephrase that..

• B must be exactly 3 less than A or B must be exactly 70?
• B must be at least 3 less than A and B must be less than or equal to 70?

What you say, "3 less than A or 70", would be:
`if (B == A - 3 || B == 70)` ..but that is probably not what you mean.

Now let's say A = 71 and B = 70.
B is 70 but B is not 3 less than A. Should the pin go high?

Now let's say A = 76 and B = 70.
B is 70 but B is not exactly 3 less than A. Should the pin go high?

Now let's say A = 72 and B = 69.
B is exactly 3 less than A, but B is not exactly 70. Should the pin go high?