Hello, I would like to set up the above so that the green element of the LED stays lit unless the sensor reads an obstacle in its path then activates the green to go off and red to illuminate. As a newbie I thought it would not be that difficult but I seem to be stuck and would be grateful for ideas ( including code ) please.
As a newbie I thought it would not be that difficult
It may amuse you that there is an official name for that common misconception: the Dunning-Kruger effect.
We recommend starting with the examples provided by the Arduino program development software. Learn to blink an LED without using delay(), read a voltage or a sensor, learn the special features of Arduino, etc. That way you avoid mountains of frustration.
PS: the U.S. is currently suffering from the Dunning-Kruger effect operating at the very highest levels.