Thesis Code
Thesis Code
GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
lcd = None
try:
lcd = LCD(address=I2C_ADDRESS)
except Exception as e:
rpm = 0
last_pulse_time = time.time() # Track the last pulse time for debounce logic
def calculate_rpm():
else:
rpm = 0
count = 0
start_time = time.time()
def display_rpm():
if lcd:
try:
lcd.text(f"RPM: {int(rpm)}", 1)
lcd.text(" ", 2)
except Exception as e:
def main():
try:
while True:
current_time = time.time()
# Debounce logic
count += 1
last_pulse_time = current_time
except KeyboardInterrupt:
except Exception as e:
finally:
if lcd:
try:
lcd.clear()
except Exception as e:
GPIO.cleanup()
if __name__ == "__main__":
main()
import time
# Pin configuration
# GPIO setup
while True:
print("Relay ON")
else:
print("Relay OFF")
except KeyboardInterrupt:
print("Exiting program...")
finally: