You Want Electronic Components for your project. 

For more information, contact us at: 

4.2 Analog Input

4.2.1 Meaning of Analog Input

An analog signal can have many different values within a specific range rather than only HIGH or LOW.

Examples of devices that can produce analog signals include:

  • Potentiometers
  • Light-dependent resistors
  • Temperature sensors
  • Gas sensors
  • Joysticks
  • Analog pressure sensors

Arduino boards with an analog-to-digital converter (ADC) can convert the voltage into a numerical value.

On many common Arduino boards such as the Arduino Uno, analogRead() returns a value from:

0 to 1023

where:

  • 0 represents approximately 0 V.
  • 1023 represents approximately the reference voltage, commonly 5 V on an Uno.

4.2.2 Reading an Analog Signal

The Arduino uses the analogRead() function:

int sensorValue = analogRead(A0);

Example:

int sensorPin = A0;

int sensorValue;

 

void setup() {

  Serial.begin(9600);

}

 

void loop() {

  sensorValue = analogRead(sensorPin);

 

  Serial.println(sensorValue);

 

  delay(500);

}

The value measured at analog pin A0 is displayed through the Serial Monitor.

4.2.3 Converting an Analog Reading to Voltage

For an Arduino Uno using a 5 V reference, the approximate voltage can be calculated as:

voltage = sensorValue * 5.0 / 1023.0;

Example:

int sensorValue;

float voltage;

 

void setup() {

  Serial.begin(9600);

}

 

void loop() {

  sensorValue = analogRead(A0);

 

  voltage = sensorValue * 5.0 / 1023.0;

 

  Serial.println(voltage);

 

  delay(500);

}

I am an ICT enthusiast and software developer with interests in web development, networking, embedded systems, and the Internet of Things (IoT). I enjoy building innovative technology solutions, learning new skills, and using technology to solve real-world problems. I am committed to continuous learning, professional growth, and delivering quality work.and also i have 3 years of teachining and developing iot project.