import machine class WaterSensor: def __init__(self, pin): self.waterSensor = machine.ADC(pin) self.reading = self.waterSensor.read_u16() self.threshold = 2000 def takeReading(self): self.reading = self.waterSensor.read_u16() def isWaterPresent(self): return self.reading > self.threshold def waterStatus(self): return 'Present' if self.isWaterPresent() else 'Absent'