Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RPi GPIO Flashing LED
#2
I think you'll have to start a Thread in swLed() that could trigger a while loop to blink the LED (if button is pressed [ON]).
If the press button is OFF you'll have to set a "global stop variable" (keep_blinking = False) to break the blink LED loop.

def my_thread_function():
    led_state = 1
    while keep_blinking:
        GPIO.output(LedPin, led_state)
        led_state = not led_state
        time.sleep(0.1)
Reply


Messages In This Thread
RPi GPIO Flashing LED - by nickayres - Jun-07-2019, 10:11 AM
RE: RPi GPIO Flashing LED - by gontajones - Jun-07-2019, 01:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  GPIO Bug? Rchrd 6 1,085 Nov-17-2024, 10:46 PM
Last Post: Rchrd
  function return boolean based on GPIO pin reading caslor 2 2,048 Feb-04-2023, 12:30 PM
Last Post: caslor
  class Update input (Gpio pin raspberry pi) caslor 2 1,700 Jan-30-2023, 08:05 PM
Last Post: caslor
  Webhook, post_data, GPIO partial changes DigitalID 2 1,902 Nov-10-2022, 09:50 PM
Last Post: deanhystad
  Seemingly unstable GPIO output while executing from RetroPie LouF 6 5,650 Feb-19-2021, 06:29 AM
Last Post: LouF
  Picture changing triggered by GPIO q_nerk 2 3,375 Dec-14-2020, 03:32 PM
Last Post: DeaD_EyE
  GPIO high if network IP has good ping duckredbeard 3 3,140 Oct-12-2020, 10:41 PM
Last Post: bowlofred
  raspberry pi tank gpio help jatgm1 1 3,297 May-06-2020, 09:00 PM
Last Post: Larz60+
  Where should I place GPIO.cleanup() shallanq 2 3,012 Apr-11-2020, 05:02 AM
Last Post: shallanq
  Orange PI Win steering LEDs connect to GPIO djmcg 0 1,981 Dec-27-2019, 08:26 AM
Last Post: djmcg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020