Попробуйте это. Вы должны установить RPi.GPIO, если не
pip install RPi.GPIO
import RPi.GPIO as GPIO
from time import sleep
# Use on of this. (visit https://pinout.xyz/ for more details)
# GPIO.setmode(GPIO.BOARD) # If you are using number on the board (1 --> 3.3V, 2 --> 5V)
GPIO.setmode(GPIO.BCM) # If you are using the Broadcom numbering
A = 5
B = 6
C = 13
D = 19
E = 26
def pic():
a = GPIO.input(A);
b = GPIO.input(B);
if a == GPIO.LOW and b == GPIO.LOW:
print("something");
GPIO.output(C, GPIO.HIGH)
GPIO.output(D, GPIO.LOW)
GPIO.output(E, GPIO.LOW)
if a == GPIO.LOW and b == GPIO.HIGH:
print("something");
GPIO.output(C, GPIO.LOW)
GPIO.output(D, GPIO.HIGH)
GPIO.output(E, GPIO.LOW)
if a == GPIO.HIGH and b == GPIO.LOW:
print("something")
GPIO.output(C, GPIO.LOW)
GPIO.output(D, GPIO.HIGH)
GPIO.output(E, GPIO.LOW)
if a == GPIO.HIGH and b == GPIO.HIGH:
print("something")
GPIO.output(C, GPIO.LOW)
GPIO.output(D, GPIO.LOW)
GPIO.output(E, GPIO.HIGH)
GPIO.setup(A, GPIO.IN)
GPIO.setup(B, GPIO.IN)
GPIO.setup(C, GPIO.OUT)
GPIO.setup(D, GPIO.OUT)
GPIO.setup(E, GPIO.OUT)
while True:
pic()
sleep(100 / 1000)
Чтобы выполнить выполнение в терминале
python filename.py