Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- from time import sleep
- delay = 1
- P1_PIN = 17
- P2_PIN = 27
- P3_PIN = 22
- S1_PIN = 23
- S2_PIN = 24
- S3_PIN = 25
- Q1_PIN = 7
- Q2_PIN = 8
- S1 = S2 = S3 = P1 = P2 = P3 = 0
- M1 = M2 = M3 = M4 = 0
- M1p = M2p = M3p = M4p = 0
- GPIO.setmode(GPIO.BCM)
- GPIO.setwarnings(False)
- GPIO.setup(P1_PIN, GPIO.IN)
- GPIO.setup(P2_PIN, GPIO.IN)
- GPIO.setup(P3_PIN, GPIO.IN)
- GPIO.setup(S1_PIN, GPIO.IN)
- GPIO.setup(S2_PIN, GPIO.IN)
- GPIO.setup(S3_PIN, GPIO.IN)
- GPIO.setup(Q1_PIN, GPIO.OUT)
- GPIO.setup(Q2_PIN, GPIO.OUT)
- while(True):
- P1 = GPIO.input(P1_PIN)
- P2 = GPIO.input(P2_PIN)
- P3 = GPIO.input(P3_PIN)
- S1 = GPIO.input(S1_PIN)
- S2 = GPIO.input(S2_PIN)
- S3 = GPIO.input(S3_PIN)
- M1p = M1 and M2 and not M4 or M1 and not M3 and M4 and not S1 or \
- not M1 and M2 and M3 and (M4 and S3 or not M4 and S2) or \
- M1 and not M2 and ( not M3 and not M4 or M3 and M4 )
- M2p = M1 and not M2 and M4 and (M3 and S3 or not M3 and S1) or \
- M2 and M4 and (M1 and not M3 or not M1 and M3) or \
- M2 and M3 and not M4 and not S2 or M2 and not M3 and not M4 or \
- not M1 and not M2 and not M3 and not M4 and S1;
- M3p = M1 and M2 and not M4 and (not M3 and P2 or M3 and not S2) or \
- M3 and M4 and not S3 and (M1 and not M2 or not M1 and M2) or \
- not M2 and not M3 and not M4 and (M1 and P3 or not M1 and S1) or \
- not M1 and M2 and not M3 and not M4 and (P2 or P3) or \
- not M1 and M2 and M3 and not M4 and not S2;
- M4p = M1 and M2 and not M3 and (not M4 and P1 or M4 and not S1) or \
- M1 and not M2 and M4 and (M3 and not S3 or not M3 and not S1) or \
- not M1 and M2 and (M3 and M4 and not S3 or not M3 and not M4 and P3) or \
- M1 and not M2 and not M3 and not M4 and (P1 or P3)
- M1 = M1p;
- M2 = M2p;
- M3 = M3p;
- M4 = M4p;
- Q1 = not M1 and not M2 and not M3 and not M4 or \
- M1 and M2 and M3 and not M4 or M1 and M2 and \
- not M3 and M4 or M1 and not M2 and not M3 and M4;
- Q2 = not M3 and not M4 and (M1 or M2);
- GPIO.output(Q1_PIN, Q1)
- GPIO.output(Q2_PIN, Q2)
- print("P: %d%d%d" % (P1, P2, P3))
- print("S: %d%d%d" % (S1, S2, S3))
- print("M: %d%d%d%d" % (M1, M2, M3, M4))
- print("Q: %d%d" % (Q1, Q2))
- print();
- sleep(delay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement