This is my code to light up my LED when I press 'l' character. In first run it works as expected. But in the second run the LED is light up at the startup. But why?? I used GPIO.cleanup() at the end.
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
def getch():
ch = input("Input: ")
return ch
print("Enter l to lightup")
print("Enter any key to exit")
while True:
char = getch()
if(char=="l"):
GPIO.output(11,GPIO.HIGH)
else:
break
GPIO.cleanup()