This tutorial discusses the analog input pins in evive, what is scaling, potentiometer, and how to read the input at the analog pins with the help of a simple Arduino IDE sketch.
Tutorial Info

## Components Required

Image Component Quantity Available in Kit
evive 1
USB A-B Cable 1

## Introduction

evive has 10 analog input pins under its magic lid. The Atmega controllers used in evive contain a total of 16 channel analog-to-digital (A/D) converter; out of these 16 channels, i.e. pins, only 10 analog inputs are available to the user. The converter has 10 bit resolution; therefore, it returns 210, i.e. 1024 values, these values being  integers from 0 to 1023. The main function of the analog pins for most Arduino users is to read analog input from analog sensors.

analogRead(pin) function reads the value from the specified analog pin. The input can range from 0V to 5V; The output is an integer value between 0 and 1023 (be to a 10 bit analog to digital converter), where 0oV, and 10235V in terms of input voltage. This process of mapping analog values to their corresponding digital values is known as scaling.In our case, scaling yields a resolution between readings of

5 volts / 1024

= .0049 V per unit

= 4.9 mV per unit

If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors, e.g. the values of the other analog inputs, how close your hand is to the board, etc.

In this example we will read the analog pin A9 and display the value on TFT Screen.

evive has two inbuilt 10kΩ knob potentiometers connected to Arduino Mega pins A9 and A10, respectively.

A potentiometer is nothing but a variable resistor, i.e. we can easily vary/change the value of the resistor by moving or turning the slider or the knob respectively. Since the movement of the slider or the knob is smooth and continuous, the change in the value of the resistance is smooth.

## Example Codes

Below is the Arduino IDE sketch that reads analog value of potentiometer and displays it on tft screen:

OUTPUT:

In the second example we will convert the scaled value back to its original analog value, i.e. the input voltage and then display in on the TFT screen. The voltage and the analog reading conversion relation is given by

Voltage = (5*A)/1023    ( where A represent the analog value of an analog Pin)

Arduino Sketch:

OUTPUT:

[tutorialRelatedProjects]