P Comp

Light Level

This week, I worked on using both digital and analog components with my Arduino. I wanted to use a photoresistor, an analog component, but I first started all with digital inputs to make sure I wired and programmed my Arduino correct. I initially forgot to connect my switch to high voltage, which caused the signal from the button switch to be inconsistent. I fixed the issue after noticing my LED not lighting properly. I made this code:

And after fixing my button switch circuit, it worked to light up my LED.

Next, I knew I needed replace the button switch, except I would need to wire it to the analog pins on the Arduino. I wanted more lights to light up based on how much light the photoresistor sensed. If it sensed more light, then more of the LEDs would light up.  Here is what my circuit diagram looks like:

And then this is the code I created:

Which then yielded this: