Keywords : Arduino Analog Inputs, ADC, Analog to Digital Conversion, Minimum Voltage, Analog Output, PWM Output, PWM, Pulse Width Modulation
Arduino Analog Inputs
Almost all the things around us are analogous. Therefore to analyze and understand them in digital world, we need to convert them into digital signals. In Arduino there are inbuilt ADCs. (Analog to Digital Conversions) In Arduino uno there are 06 no of 10-bit Analog inputs available. Some micro-controllers support 8-bit and some even support 12-bit ADC.What is the resolution
Lets take an Arduino Uno (10-bit ADC). It can show 210 no of different values. (1024 Values, from 0 to 1023)
To see an application, refer Arduino ReadAnalogVoltage Example
Arduino IDE >> File >> Examples >> 01.Basics >> ReadAnalogVoltage
Lets get to the example
Connections for ADC read using Serial Communication |
To access the code, go to,
Arduino IDE >> File >> Examples >> 01.Basics >> AnalogReadSerial
I've used tinkercad to simulate the result and see how value changed when I rotate the potentiometer.
Also delay after the ADC read was added to slow down the reading and show you how it changed. You may not need to add it.
ADC - AnalogReadSerial Simulation |
Arduino PWM (Pulse Width Modulation) Outputs
Arduino boards are not capable of providing analog outputs. (We'll discuss how to get analog outputs using DAC-Digital to Analog converter modules) But there are occasions that we can utilize PWM outputs to some of the applications. (ex: LED dimming) Also PWM signals are very much important in DC motor speed controlling and RC Servo position controlling and generation Audio signals. Also using filters we can make analog signals.(hard to create pure analog signals)Read Analog from A0 and Write to Pin 09 PWM |
int ledOut = 9; //You can select only PWM Pins
int BrightnessValue = 0; //Assign PWM value to control Brightness
void setup() {
pinMode(ledOut, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int AnalogReadValue = analogRead(A0); //Read the analog value from POT
BrightnessValue = map(AnalogReadValue, 0, 1023, 0, 255);
/*Mapping 10-bit ADC value into 8-bit PWM value through map function*/
analogWrite(ledOut, BrightnessValue); //Write the PWM Value
}