I have a simple python script :


import RPi.GPIO as GPIO
import time
from time import *


GPIO.setup(4, GPIO.OUT)

while True:
    sleep (1)
    input = GPIO.input(26)
    if input:

Should I avoid switching on a GPIO Pin every second or should I only switch it once the button changes its return value? I switch a LED on and off.

1 Answer 1


You can switch a GPIO on and off as frequently as you want. It will not be harmed.

If the GPIO is used to switch an external circuit on and off you would have to consider what you are switching. E.g. if the GPIO is used to switch a mechanical relay you might want to limit the frequency. The relay will likely have a limited lifetime measured in tens of thousands of activations.

  • it's just a LED
    – Motte001
    Jul 2, 2016 at 22:43
  • 3
    A LED will be fine.
    – joan
    Jul 3, 2016 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.