Photo Resistor

OHMS law = I = V/R


CODE

# Module Import

import LocoIOT

import time


# Class Instances Creation

loco_iot = LocoIOT.LocoIOT()

msg = LocoIOT.IOT_Codes()


# Initiate Connection to the Microcontroller

loco_iot.connect()



### Add Hardware Enable(s) Here

loco_iot.enable(msg.SUBTYPE_PHOTO)

loco_iot.enable(msg.SUBTYPE_DO_1)


# Start Listening for Control/Request Messages

loco_iot.start()


start_time = time.time()

while (time.time() - start_time) < 60:


# QUESTION CODE GOES HERE

light_dict = loco_iot.getData(msg.SUBTYPE_PHOTO)

print(light_dict["Photocell"])

if light_dict["Photocell"] >= 100:

loco_iot.setData(msg.SUBTYPE_DO_1, [1])

else:

loco_iot.setData(msg.SUBTYPE_DO_1, [0])

print("Stop screwing up")

# Short Arbitrary Delay

time.sleep(0.1)



# Close Connection to the Microcontroller

loco_iot.close()