On 28/04/2025 10:07, Ralph Corderoy wrote:
Some alternatives to try to gather more observations.
- Discard the try...except:
while True:
led_cycle()
Ignoring the loss of GPIO.cleanup() for the moment. Does the
behaviour now change suggesting exception handling is involved?
The behaviour is identical.
- Comment out the call to traffic_lights() in led_cycle(). What
happens? Perhaps the same behaviour transfers to location_lights(),
with sensor_lights() and the print() still not occurring. Or perhaps
it now cycles as desired.
That's weird! The traffic_lights() function is still executed!
Here is a fragment of the code at the beginning of the function. I have
shown a representation of the GPIO setup code that precedes the function
definition and the first few lines of the function itself. The string
traffic_lights() only appears twice in the code; in the definition as
below and in the commented out call:
GPIO.setup(button_pressed, GPIO.IN, pull_up_down=GPIO.PUD_UP) #
Button pin
GPIO.setup(button_illumination, GPIO.OUT) #
Button illumination
print("All LEDs OFF.")
input("Press Enter")
def traffic_lights():
GPIO.output(back_green, GPIO.LOW) # Set all Traffic lights off
GPIO.output(out_green, GPIO.LOW)
GPIO.output(back_red, GPIO.LOW)
GPIO.output(out_red, GPIO.LOW)
# Check Traffic Lights
print("Checking Traffic Lights. All Lights Off")
print("")
input("Press Enter")
--
Terry Coles
--
Next meeting: Online, Jitsi, Tuesday, 2025-05-06 20:00
Check to whom you are replying
Meetings, mailing list, IRC, ... https://dorset.lug.org.uk
New thread, don't hijack: mailto:dorset@mailman.lug.org.uk