i ran your code through chatgpt and it spit out this to correct errors.
Code:
import gpiozerofrom gpiozero import Button, OutputDeviceimport time# Length of time to water manually (in minutes)manual_time = 2manual_time2 = 5# Initialize buttonbutton = Button(6)# Manual Watering Functiondef manual(water_count, valve_pin, watering_time): valve = gpiozero.OutputDevice(valve_pin) if not valve.value and water_count < 1: valve.on() time.sleep(1) time.sleep(watering_time * 60) valve.off() water_count += 1 else: print("Garden already watered today")# Listen for Button Pressdef button_pressed(): global waterCount, waterCount2 manual(waterCount, 26, manual_time) manual(waterCount2, 4, manual_time2)button.when_pressed = button_pressedtry: while True: time.sleep(1) # Keep the program runningexcept KeyboardInterrupt: pass # Handle Ctrl+C gracefullyfinally: gpiozero.close_all() # Clean up GPIO resourcesStatistics: Posted by kerry_s — Fri Jun 07, 2024 3:01 am