Changed GPIO pins as per connections.md file.
This commit is contained in:
parent
34b0bf01e9
commit
4e1a7a848a
@ -12,14 +12,14 @@ import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO setwarnings(False)
|
||||
GPIO.setup(12,GPIO.OUT)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print(“LED ON”)
|
||||
GPIO.output(12,GPIO.HIGH)
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print(“LED OFF”)
|
||||
GPIO.output(12,GPIO.LOW)
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
@ -31,17 +31,17 @@ import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO setwarnings(False)
|
||||
GPIO.setup(12,GPIO.OUT)
|
||||
GPIO.setup(19,GPIO.OUT)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
GPIO.setup(26,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print(“LED ON”)
|
||||
GPIO.output(12,GPIO.HIGH)
|
||||
GPIO.output(19,GPIO.HIGH)
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
GPIO.output(26,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print(“LED OFF”)
|
||||
GPIO.output(12,GPIO.LOW)
|
||||
GPIO.output(19,GPIO.LOW)
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
GPIO.output(26,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
@ -53,17 +53,17 @@ import RPi.GPIO as GPIO
|
||||
import time
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(12,GPIO.OUT)
|
||||
GPIO.setup(19,GPIO.OUT)
|
||||
GPIO.setup(16,GPIO.OUT)
|
||||
GPIO.setup(26,GPIO.OUT)
|
||||
try:
|
||||
while True:
|
||||
print("LED Buzzer ON")
|
||||
GPIO.output(12,GPIO.HIGH)
|
||||
GPIO.output(19,GPIO.HIGH)
|
||||
GPIO.output(16,GPIO.HIGH)
|
||||
GPIO.output(26,GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
print("LED & Buzzer OFF")
|
||||
GPIO.output(12,GPIO.LOW)
|
||||
GPIO.output(19,GPIO.LOW)
|
||||
GPIO.output(16,GPIO.LOW)
|
||||
GPIO.output(26,GPIO.LOW)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
0
Practical/Assignment-3/IoT - Code-3.py
Executable file → Normal file
0
Practical/Assignment-3/IoT - Code-3.py
Executable file → Normal file
@ -14,14 +14,14 @@ GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.cleanup()
|
||||
GPIO.setup(16, GPIO.IN) # Set GPIO 16 as input for water level sensor signal
|
||||
GPIO.setup(6, GPIO.OUT) # Set GPIO 6 as output for LED
|
||||
GPIO.setup(26, GPIO.OUT) # Set GPIO 6 as output for LED
|
||||
|
||||
try:
|
||||
while True:
|
||||
if (GPIO.input(16))
|
||||
GPIO.output(6, True) # Turn ON LED if water detected
|
||||
GPIO.output(26, True) # Turn ON LED if water detected
|
||||
else
|
||||
GPIO.output(6, False) # Keep LED OFF if no water detected
|
||||
GPIO.output(26, False) # Keep LED OFF if no water detected
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
print("Program exited by user.")
|
||||
|
Loading…
Reference in New Issue
Block a user