Hi Terry,
> # Calculate how many times to continue checking if the has passed a
> Sensor.
> sensor_pause_time = 0.05 # Time in seconds for the program to pause
> each time round the Sensor test loop.
>
> # Calculate number of loops in out leg.
> sensor_test_time_out = 8 # Time in seconds required.
> sensor_test_loops_out = (sensor_test_time_out / sensor_pause_time)
> print(sensor_test_loops_out)
An alternative method, if you end up re-working this section:
deadline = time.time() + sensor_test_time_out
while time.time() < deadline:
if GPIO.input(sensor_b):
break
time.sleep(sensor_pause_time)
Removes one variable, and it copes with creep though will still run past
deadline on the final iteration.
If the loop should execute at least once, then there's the explicit:
deadline = time.time() + sensor_test_time_out
while True:
if GPIO.input(sensor_b):
break
if time.time() >= deadline:
break
time.sleep(sensor_pause_time)
> I won't get back on site until early next week, but I'll certainly check
> this out.
It may be worth checking the code, or at least a fragment of it with the
GPIO logic, away from the main hardware so you can manually alter the
GPIO pin's value to debug the logic.
--
Cheers, Ralph.
--
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]