Moved water level code to assignment 6 and renamed it.
This commit is contained in:
parent
819932c459
commit
791d023fba
@ -16,11 +16,13 @@ GPIO.cleanup()
|
|||||||
GPIO.setup(16, GPIO.IN) # Set GPIO 16 as input for water level sensor signal
|
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(6, GPIO.OUT) # Set GPIO 6 as output for LED
|
||||||
|
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
if (GPIO.input(16))
|
if (GPIO.input(16))
|
||||||
GPIO.output(6, True) # Turn ON LED if water detected
|
GPIO.output(6, True) # Turn ON LED if water detected
|
||||||
else
|
else
|
||||||
GPIO.output(6, False) # Keep LED OFF if no water detected
|
GPIO.output(6, False) # Keep LED OFF if no water detected
|
||||||
|
except KeyboardInterrupt:
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
print("Program exited by user.")
|
||||||
# END OF CODE
|
# END OF CODE
|
@ -1,26 +0,0 @@
|
|||||||
"""
|
|
||||||
THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B, 4B AND IS FULLY OPERATIONAL.
|
|
||||||
|
|
||||||
Problem Statement: Water level
|
|
||||||
|
|
||||||
Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems
|
|
||||||
"""
|
|
||||||
|
|
||||||
# BEGINNING OF CODE
|
|
||||||
import RPi.GPIO as GPIO # Import library
|
|
||||||
|
|
||||||
# Initalize GPIO
|
|
||||||
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
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if (GPIO.input(16))
|
|
||||||
GPIO.output(6, True) # Turn ON LED if water detected
|
|
||||||
else
|
|
||||||
GPIO.output(6, False) # Keep LED OFF if no water detected
|
|
||||||
|
|
||||||
GPIO.cleanup()
|
|
||||||
# END OF CODE
|
|
Loading…
Reference in New Issue
Block a user