4 Arduino ANALOG reading in Light sensor analogRead

Опубликовано: 21 Апрель 2026
на канале: ENGRTUTOR
2,397
5

In the previous video we saw the Light Sensor in a voltage divider configuration. In this video instead of a voltmeter and a separate power supply, we want to be able to use the Arduino to measure these analog voltage changes from our voltage divider. Let's setup the circuit

The photo-resistor is in a voltage divider configuration. The power supply is replaced by 5V and GND from the Arduino. The junction of the fixed 1k resistor and our photo-resistor is wired and sent to ANALOG IN port pin A0 of the Arduino.

We want to read voltage across the photo-resistor through analog port A0. If you go to the Arduino function reference at https://www.arduino.cc/reference/en/#... you will find the following listed as Analog I/O:

analogRead()

The analog functions are a little different from the digital ones that we have encountered so far. First, as we discussed earlier, the readings are in a continuous range from 0 to 1023 not HIGH/LOW and second, we do not need a setup for pinMode(). The Analog ports A0-A6 are marked Analog In; they do not work as analog output ports.

In this section, we will work primarily with analogRead() function. This function takes in a analog pin as a parameter (A0 to A5) and reads the value from the specified analog pin. The function returns an integer so we will need an int data-type to store its value.