logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

The Basics of Arduino: Reading Voltage

DevicePlus Editorial Team
Published by DevicePlus Editorial Team at December 22, 2021
Categories
  • Arduino
Tags
connecting volume pod to arduino

Originally published by Mar 31, 2020

This article was translated to English, and was originally published for deviceplus.jp.

Table of Contents

  1. Introduction
  2. Convert analog values to digital values
  3. Analog input with Arduino
  4. Adjust voltage with Volume
  5. Analog input with Volume
  6. Conclusion
  7. Related articles

Introduction

With digital input, 5V can be read as HIGH and 0V as LOW. You can determine whether a switch is on based on which state it is in. However, electricity is not only 5V and 0V, but various voltages. For example, one AA battery is 1.5V, and a household outlet is 100V.

Arduino supports analog inputs to read these various voltages. Analog inputs enable you to read the state of electronic components that change gradually. For example, you can use volume to adjust brightness or loudness or a temperature sensor to get the current temperature.

voltage can be read from analog input

This article is the last in the series. We will explain analog input using volume.

Convert analog values to digital values

Actual voltage is not an exact value such as 1V or 5V, but an irrational number, in which numerical values continue forever after the decimal point, such as 5.01342…V. These values cannot be directly handled by a computer. In electronic circuits, therefore, analog values are converted to digital values using a mechanism called AD converter so that the value can be handled by a computer. Arduino also has an AD converter by default, which can read analog voltages and convert them into digital values.

The AD converter divides the target voltage into several equal parts. For Arduino Uno, voltages can be read in the range of 0-5V. These 0-5V values are divided into 1023 equal parts. The AD converter converts the analog voltage reading to the nearest equal value. If the voltage is 3V, for example, “614” is the closest value. This value can be sent to Arduino for use.

how the analog value is converted to digital value

Integer values up to 1023 are used to process the program. However, the input value is not a voltage value. If you want to know the voltage value, you can calculate it as follows:
how to calculate the voltage

For example, if the value from the AD converter is “614”, you can obtain about 3V by dividing by 1023 and then multiplying by 5.

Analog input with Arduino

With Arduino Uno, you can use six pins for digital input, A0 to A5. By connecting electronic components here for the input, you can read how much voltage is applied. However, pins A4 and A5 are also used for digital communication called I2C. Note that these pins cannot be used for analog input when connecting electronic components such as sensors or displays that use I2C digital communication.

pins that support analog input

Adjust voltage with Volume

“Volume” is an electronic part that can be used to adjust the audio volume or lighting brightness. The volume contains terminals moving on the resistive element. The resistance can be changed by moving these terminals.

The volume generally has three terminals. The left and right terminals are attached to both ends of the resistor. The center terminal is designed to move on the resistive element. If you move the center terminal to the right, the resistance between the left and center terminals increases. Conversely, if you move it to the left, the resistance decreases.

how the volume works

In the figure above, the resistance element is linear, but in the rotary volume, the internal resistance element is circular. Although the shapes are different, they basically operate the same way.

The Arduino analog input uses the voltage change for the input. Since the resistance changes in the volume, however, it is not possible to read the volume change by connecting it directly to Arduino. Therefore, the resistance change should be converted to a voltage change. Connect the power supply and GND to the left and right terminals of the resistor. The voltage at the center terminal changes depending on the terminal position. Assume that the left terminal is connected to GND, and the right terminal is connected to a power supply (5V). The voltage increases as the center terminal moves to the right, and it decreases as the terminal moves to the left. The left end is 0V and the right end is 5V, so the value can be changed within the range of 0 to 5V.

If this center terminal is connected to the Arduino analog input terminal, the input can be changed by moving the volume.

how the volume works

Analog input with Volume

Now let’s try analog input using the volume. Prepare the following electronic components.
Volume pod
volume pod

The volume pod contains the resistance value of the range that can be changed. It is good to use a 10kΩ volume for the Arduino input. The volume will be easier to move, if a knob is attached to the rotation axis of the volume.

Alligator-clip jumper line
alligator clip jumper line

Useful for attaching a volume pod. Pinch the volume terminals with the clip-shaped connectors. The linked product is available as a set of two red lines and two black lines.

When you have prepared the components, connect them as shown in the figure below. Since the volume pod cannot be plugged into the breadboard, use an alligator-clip jumper line to connect it directly to Arduino. Make sure that the metal part of the alligator clip does not touch the adjacent clip part.

connecting volume pod to arduino

Write the following program:

To check the state where the analog input pin is connected, specify the target pin in “analogRead()” (line 11). Then, input the voltage of the pin with the value of 0 to 1023. If you want to know the voltage, it is calculated and converted to voltage as in line 13.

Write the program to Arduino and display the serial monitor.
The value digitized by the AD converter is displayed after “Value:”, and the value calculated and converted into voltage is displayed after “Volt:”. You can see that the value changes as the volume is rotated.

converted value and volt

Conclusion

In this series, we introduced the usage underlying Arduino. Try operating a variety of electronic components and creating programs based on the content explained in this series. Thank you very much for following this half-year series to the end!

Related Articles

Explore the rest of this series to get to know about the basics of Arduino:

  • The Basics of Arduino: Adjusting LED Brightness
  • The Basics of Arduino: Controlling the Motor
  • The Basics of Arduino: Reading Switch States
  • The Basics of Arduino: Control LED Lighting with Digital Output
  • The Basics of Arduino: Prepping the Arduino
DevicePlus Editorial Team
DevicePlus Editorial Team

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • The Basics of Arduino: Adjusting LED BrightnessThe Basics of Arduino: Adjusting LED Brightness
  • The Basics of Arduino: Reading Switch StatesThe Basics of Arduino: Reading Switch States
  • The Basics Of Arduino: Control LED Lighting with Digital OutputThe Basics Of Arduino: Control LED Lighting with Digital Output
  • Use Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the SteeringUse Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the Steering
  • Arduino Communication Protocols TutorialArduino Communication Protocols Tutorial
  • Using Arduino with Parts and Sensors – Solar Powered Arduino (Part 1)Using Arduino with Parts and Sensors – Solar Powered Arduino (Part 1)
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort