Gumawa kasi kami ng project vending machine eto code po.
Raspberry pi po gamit
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Reader
GPIO.setup(4, GPIO.IN)
# Relay 1
GPIO.setup(25, GPIO.OUT)
# Push Button
GPIO.setup(23, GPIO.IN)
# Sensor
GPIO.setup(22, GPIO.IN)
print('Please swipe your card')
try:
while True:
reader=GPIO.input(4)
button=GPIO.input(23)
sensor=GPIO.input(22)
if reader==1:
input (button==1)
else:
input (button==0)
while True:
if button==1:
GPIutput(25, GPIO.LOW)
time.sleep(1)
if sensor==0:
GPIutput(25, GPIO.HIGH)
time.sleep(1)
finally:
GPIO.cleanup()
Raspberry pi po gamit
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Reader
GPIO.setup(4, GPIO.IN)
# Relay 1
GPIO.setup(25, GPIO.OUT)
# Push Button
GPIO.setup(23, GPIO.IN)
# Sensor
GPIO.setup(22, GPIO.IN)
print('Please swipe your card')
try:
while True:
reader=GPIO.input(4)
button=GPIO.input(23)
sensor=GPIO.input(22)
if reader==1:
input (button==1)
else:
input (button==0)
while True:
if button==1:
GPIutput(25, GPIO.LOW)
time.sleep(1)
if sensor==0:
GPIutput(25, GPIO.HIGH)
time.sleep(1)
finally:
GPIO.cleanup()