Adding an analog sensor

From SquidBee

Jump to: navigation, search

First of all let's see something about analog sensors.

An analog sensor is a component than measures any actual magnitude and translates its value into a magnitude than we can measure with an electronic circuit, normally a resistor or capacitive value than we can convert into a voltage value (normally between 0V and 5V). Finally we can get this value into our microcontroller using one of its analog input pin.

Most of the analog sensors we're going to use are resistive senors, the connexion we have to make is very simple (figure 1)

resistive sensor connection
resistive sensor connection

Sensor is the resistive sensor and R usually is 1 kohms or 10 kohms

Once the sensor is connected to Arduino you can get the value in your arduino program with the analogRead function

just type in your programm

val == analogRead(pin);

val is the variable to store the value and pin is the number of the analog pin (0-5)

After the analog to digital conversion val you'll get in val a number between 0 and 1023, what means 0 - 0V and 1023 - 5V and so on.

There are also some sensors than offer an analog output, so you can connect it directly to the analog input

analog sensor
analog sensor

take care of the value range in the analog input in arduino, it must be between 0V - 5V

Personal tools