Hardware Reference
In-Depth Information
Figure 3-11: Photoresistor circuit
value is the information you are starting with. In your case, that's the most
recent reading from the analog input. fromLow and fromHigh are the input
boundaries. These are values you found to correspond to the minimum and
maximum brightness in your room. In my case, they were 200 and 900 . toLow
and toHigh are the values you want to map them to. Because analogWrite()
expects value between 0 and 255 , you use those values. However, we want a
darker room to map to a brighter LED. Therefore, when the input from the ADC
is a low value, you want the output to the LED to be a high value, and vice versa.
Search WWH ::




Custom Search