Syntax:
analogRead(Pin);
where "Pin" represents the pin number of the input pin which read from. Furthermore, the return value is integers from 0 to 1023 and the analog value can be read from 0 to 5V. Therefore, the resolution of measurement is approximately 4.88mV.
In the test, we design the circuit that voltage of photo-resistor can be read via Arduino UNO. Therefore, the power supply (+5V) is connected to the resistor, one terminal of photo-resistor is connected to ground and another terminal is connected to the Arduino (e.g. A0) as shown in following Figure 1.
Figure 1: Circuit for testing data reading
After that, upload the program from computer to Arduino board and then open the Serial Monitor. Observe the voltage of photo-resistor as shown in following Figure 2:
Figure 2: Voltage of photo-resistor
When the strength of light increase, the voltage of photo-resistor becomes smaller as shown in following Figure 3:
Figure 3: Voltage of photo-resistor with increasing strength of light
When the strength of light decrease, the voltage of photo-resistor becomes larger as shown in following Figure 4:




No comments:
Post a Comment