from RPi import GPIO global ON global OFF OFF = GPIO.LOW ON = GPIO.HIGH GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(21, GPIO.OUT) x = open(testo.txt") if x.read() == "true": GPIO.output(21, ON) else: GPIO.output(21, OFF)
I need to set high/low an output of my raspberry pi 4 from windows .bat file. Inside the .bat file I create a text file containing either true or false. If the text is true the output goes high, if it is false it goes low.
My program reads the contents of the file but the IF doesn't work; it read only the content of the ELSE, even if the text file contains true. do you know why?