import mraa
import time
class Counter(object):
count = 0
c = Counter()
def check_switch(args):
if c.count % 2 == 0:
led.write(1)
else:
led.write(0)
c.count += 1
led = mraa.Gpio(6)
led.dir(mraa.DIR_OUT)
switch = mraa.Gpio(2)
switch.dir(mraa.DIR_IN)
switch.isr(mraa.EDGE_BOTH, check_switch, 1)
time.sleep(500)
import mraa
import time
threthold = 400
light = mraa.Aio(1)
led = mraa.Gpio(6)
led.dir(mraa.DIR_OUT)
def check_light():
print(light.read())
if threthold > light.read():
led.write(1)
else:
led.write(0)
while True:
check_light()
time.sleep(3)