Created
May 26, 2021 22:07
-
-
Save nasajpledu/b7c82ef756bc86eeaef1b686927b3638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment