EFA:Sensors:Reading Analog Sensors

Sensors with Analog Voltage Output

Many sensors will just give you an analog voltage. Some common sensors with analog output that you might see and use:

  • ADXL335 – Three-axis accelerometer with analog output. Easy to use.

Variable Resistors

Many sensors are just resistors that change their resistance value based on some external input (light, temperature, force etc.). The Arduino is not able to read the change in resistance directly, but we can convert that resistance change into a change in voltage using a voltage divider.

Voltage Divider

If you connect two resistors in series as in the image below, the voltage read from Vout depends on the ratio of the two resistors. Read the Wikipedia article or check this tutorial from Sparkfun, if you want to learn how to calculate the values.


Potentiometers are essentially voltage dividers built inside a handy interface. They come in different shapes and sizes, but all of them work roughly the same way.

Light Dependant Resistor (LDR, photocell, light sensor)

This can be used to read the values from various sensors, such as the light sensor we are using.



// Read and display the value from the light sensor.

int lightSensor = 0;

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  lightSensor = analogRead(A0);
  Serial.print("light: ");