Thank you very much for this, Steve.

I 'll correct the program flow as you describe and will then investigate the voltages on D.0;

I think I will need to simplify the wiring first, get it working and then reconnect the complicated bits ...

Tony