from gpiozero import LED | |
from ptprotoplus import adc | |
from time import sleep | |
from multiprocessing import Process | |
uvled = LED(4) | |
redled = LED(10) | |
irled = LED(11) | |
light = adc.ADCProbe() | |
print("Transmitting") | |
def loop1(): | |
while 1: | |
uvled.on() | |
sleep(3) | |
print(light.read_value(0)) | |
uvled.off() | |
redled.on() | |
sleep(3) | |
print(light.read_value(0)) | |
redled.off() | |
irled.on() | |
sleep(3) | |
print(light.read_value(0)) | |
irled.off() | |
def loop2(): | |
while 1: | |
if light.read_value(0) > 120: | |
print("receiving") | |
sleep(2) | |
else: | |
print("...") | |
sleep(2) | |
if __name__ == '__main__': | |
lights = Process(target=loop1) | |
sensor = Process(target=loop2) | |
lights.start() | |
sensor.start() | |
lights.join() | |
sensor.join() |