code optimisation - stuck.

Thanks both.

I "shot myself in the foot" because I was cut/pasting and forgot to change the == 0 to == 1 in the second instance.

I was pulling my hair out wondering why it wasn't working.

Then I got to thinking that as the "flag" is only 0 or 1, that it could be used as the state - as it pretty well is anyway - to write to the output.

Yeah, the end may not be the best. There was more code but I negated it as it wasn't important.

The routine only returns when I need to know the status.

Now you have me wondering:
As it returns "light_status" in some instances, and NOTHING in others, is there a problem waiting to be discovered?

Should I make it return 0 for the other time/s when nothing is happening? But then I would have to change the line calling it too - wouldn't I?

(Got to go home and read more in the C++ book)