On 30/04/2026 15:37, Terry Coles wrote:

To clarify this, the code below is what is in Github from four years ago, eg when it all worked.  Back then the sensor was only triggered when a train went over the sensor, whereas, the current setup all the sensors are triggered /until/  a train passes.

The current code therefore removes the 'not' in the if statement.

      i = sensor_test_loops_out                       # Set the loop counter to give the required time testing for the sensor

        while i >= 0:
            i = i -1
            if not GPIO.input(sensor_b):
                time.sleep(sensor_pause_time)
            else:
                print ("Sensor B Activated")
                break
Unless I am battier than I thought, the while loop should continue until the signal goes low.  Any dissenters?

--
Terry Coles

--
 Next meeting: Online, Jitsi, Tuesday, 2026-05-05 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
 New thread, don't hijack:  mailto:[email protected]

Reply via email to