This is where we can add other cool sensors to our Arduino. Remember analogRead is really a voltage comparator.
This means that we will actually be comparing two resistors to each other and will be able to determine exactly how different they are. This is not
so interesting if we have two fixed resistors, but becomes cool when we have one fixed and one variable resistor. So far, the only variable resistors we've used are potentiometers. Now we're going to introduce photoresistors and thermistors. Photresistors change value depending on light level, while thermistors change based on temperature. Both can be used in the same way. The circuit to the right shows the circuit diagram you could use with either of these. You'll notice that there is a variable resistor and a fixed resistor both hooked up to your analog pin. For a fixed resistor try 10k ohms. The circuit below is the same one we used for the potentiometer circuit. Again, we need an LED in digital pin 13. Set up the Arduino with the circuit and the program and answer the questions below.
![]()
This will then adjust the flash rate to precisely match the light level. Next change this to fade an LED based on brightness. Note, all of this could be done with a thermistor. So that rather than light level, temperature controls things. Picture a fan that kicks on if temp gets to high. Or maybe you set up the tri color LED to be red when it's hot and blue when it's cold. It won't be the first time something like this has been done. |