Perfecting motion
Were you able to find any flaws in the previous code? They are not hard to find; the code works brilliantly when it's only a single person in the room. If this is installed somewhere where multiple people are coming and going, then it might be challenging. This is because whenever a person moves outside, the light will be turned off.
So now that the problem is evident, it's time to make the code even more better. To do this, the hardware will remain exactly the same; we simply need to make the code smarter. Let's see how we can do that:
import GPIO library import RPi.GPIO as GPIO import time import time import Adafruit_ADS1x15 adc0 = Adafruit_ADS1x15.ADS1115() GAIN = 1 adc0.start_adc(0, gain=GAIN) adc1.start_adc(1, gain=GAIN) GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) PCount = 0 while True: F_value = adc0.get_last_result() F1 = (1.0 / (F_value / 13.15)) - 0.35 time.sleep(0.1) F_value = adc0.get_last_result() F2 = (1.0 / (F_value / 13.15...