How to read Analog Input at evive's Analog Pins
About This Tutorial
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)
How to use evive’s Slide Switch
This Arduino switch tutorial discusses different types of switches based on their pole and throw, Slide Switch Definition, Arduino switch code and a simple Arduino IDE sketch to display the state of evive's slide switch on the TFT screen. Arduino toggle switch code is also given in the content.
How to generate Analog Output at Digital Pins using PWM
This Pulse Width Modulation Arduino tutorial discusses what is PWM in Arduino (Pulse Width Modulation), Arduino analogwrite function and how to generate analog output in evive using PWM with the help of an Arduino IDE sketch. Information about analogwrite Arduino function is also given in the content.