forked from ChristopherRush/BB-Evil-Genius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject 27.py
42 lines (35 loc) · 1.02 KB
/
Project 27.py
1
import Adafruit_BBIO.GPIO as GPIOimport Adafruit_BBIO.ADC as ADCfrom time import sleepGPIO.setup("P9_12", GPIO.OUT) #buzzerGPIO.setup("P9_14", GPIO.OUT)GPIO.setup("P9_16", GPIO.OUT)GPIO.setup("P9_18", GPIO.OUT)while True: def beep(): GPIO.output("P9_12", GPIO.HIGH) sleep(1) GPIO.output("P9_12", GPIO.LOW) sleep(1) ADC.setup() value = ADC.read("P9_40") value2 = ADC.read("P9_38") voltagePOT = value * 1.8 #1.8V voltagePIN = value2 * 1.8 print (voltagePOT) print (voltagePIN) sleep(1) if (voltagePIN > voltagePOT * 1.1): GPIO.output("P9_14", GPIO.HIGH) GPIO.output("P9_16", GPIO.LOW) GPIO.output("P9_18", GPIO.LOW) beep() elif (voltagePIN < voltagePOT * 1.1): GPIO.output("P9_14", GPIO.LOW) GPIO.output("P9_16", GPIO.HIGH) GPIO.output("P9_18", GPIO.LOW) else: GPIO.output("P9_14", GPIO.LOW) GPIO.output("P9_16", GPIO.LOW) GPIO.output("P9_18", GPIO.HIGH) sleep(5)