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 0 = oV, and 1023 = 5V 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
Example: Displaying analog input on TFT Screen
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.
Below is the Arduino IDE sketch that reads analog value of potentiometer and displays it on tft screen:
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)