Theory:
Photoresistors detect changes in light. There is already technology that use photoresistors like the backlight of your phone changing, or street lights turning on when it’s dark. Your devices will be able to tell us exactly how bright it is in the room.
Practical:
This is a photoresistor. We’ll be using AO only (standing for analogue output).
This is our OLED screen.
This is the circuit.
To code this, we’ll want to download the extension “iot-environment-kit” by searching “dht”.
Once it’s in, we’ll want to go to the OLED section and get initialise OLED and put that block into on start.
We then want to tell the user what is being measured so we’ll grab a show string block from OLED and type “light level: “. We then need to show the number so we’ll get a show number block and place an analog read pin p0 in. Next we add a pause block for 2 seconds and then a clear OLED display so our screen will update every 2 seconds without clogging up our screen.
Download and test your code by placing your finger over the top of the light sensor and watch the number go down.