Back to Parent

Outcome


1. Outcome

The final work I completed combines input from a photocell sensor as well a button. To complete this, I wired the two inputs/sensors separately and used a digital and analog pin for each. Here is a demonstration of the wiring:


Screen shot 2023 11 08 at 2.49.15 pm.thumb
Show Advanced Options

Here is a video for it working. The button controls whether the system if on/off. When it is held down, the LED is turned on and the photo sensor will change the brightness of LED (lower lighting would lower the LED brightness). This is the code that controls it:

Show Advanced Options

The process of developing is was quite straight forward: I first only added one sensor (the photosensor). At first the brightness didn't change a lot, and after some thinking, I found that changing the input range of the map function to be smaller will make the brightness change more noticeable. After I got this system working, I added a button as a second input, and revised the code to include the button state. 

Reflection:

I definitely became a lot more familiar with how to connect input, and make dynamic changes to the system using if statements. I enjoyed this lab because often, the IoTs in daily lives will involve at least one user inputs. One improvement I'd make is perhaps making the brightness of the LED increase (instead of decrease which is what I have done) when it is darker, because that would make more sense in real life. 

Drop files here or click to select

You can upload files of up to 20MB using this form.