Changing the test colour - condiction on a sensor value

Please format your code properly - very difficult to read otherwise.

How to format your code in forum posts.