This code does not turn the led on and off.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
GPIO.cleanup()
but when I print out the number in the loop it does work:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
for number in range(0,10):
GPIO.output(21,GPIO.LOW)
time.sleep(1)
GPIO.output(21,GPIO.HIGH)
print(number)
GPIO.cleanup()
Any idea why that is?