from machine import Pin,Timer,PWM
import time
ldr1=Pin(25,Pin.OUT)
ldr2=Pin(26,Pin.OUT)
ldr3=Pin(27,Pin.OUT)
pir1=Pin(33,Pin.OUT,Pin.PULL_UP)
R=PWM(Pin(17),freq=900,duty=0)
G=PWM(Pin(16),freq=900,duty=0)
B=PWM(Pin(4),freq=900,duty=0)
Servo=PWM(Pin(5),freq=50,duty=0)
running=True
while running:
if pir1.value()==1:
if ldr2.value()==1 and ldr1.value()==1:
R.duty(1023)
G.duty(1023)
B.duty(0)
elif ldr1.value()==0 or ldr2.value()==0:
R.duty(1023)
G.duty(0)
B.duty(0)
else :
if ldr1.value()==0 and ldr2.value()==0:
R.duty(1023)
G.duty(0)
B.duty(0)
elif ldr1.value()==1 and ldr2.value()==1:
R.duty(0)
G.duty(1023)
B.duty(0)
else:
R.duty(1023)
G.duty(1023)
B.duty(0)
# def fun(sen1,sen2):