Print Arduino ADC values on 7-segment display

This Arduino project shows how to read analog voltages from analog channel and print the digital values on 7-segment display. A potentiometer is used to get a voltage that varies between 0 and 5V.
A common anode 7-segment display is used in this example.

Last time I made a simple interfacing of Arduino UNO with 7-segment display, project link is below:
Interfacing Arduino with 7-segment display | 4-Digit counter example

Hardware Required:

  • Arduino UNO board
  • 4-Digit common anode 7-segment display
  • 4 x PNP transistor (2SA1015, 2S9015, 2N3906 …)
  • 10k ohm potentiometer
  • 7 x 100 ohm resistor
  • 4 x 4.7k ohm resistor
  • Breadboard
  • Jumper wires

Print Arduino ADC values on 7-segment display circuit:
The following image shows circuit diagram of the example.

Arduino ADC 7 segment display circuit

The four transistors used in this example are of the same type (PNP).
The potentiometer has 3 pins VCC , out and GND where:
VCC is connected to Arduino 5V pin
out is connected to Arduino analog channel 0 (A0)
GND is connected to Arduino GND pin

Print Arduino ADC values on 7-segment display code:
The following Arduino code does not use any library for the 7-segment display.

The output pin of the potentiometer is connected to Arduino analog channel 0, it is defined in the code with the following line:

The ATmega328P (Arduino uno microcontroller) has one ADC module with 10-bit resolution which means it will map input voltages between 0 and 5 volts into integer values between 0 and 1023.
So reading from analog channel will give us a digital value between 0 and 1023.

The following line is used in the code for reading analog data (voltage) from POT channel (previously defined as channel 0) and storing it in an integer variable named ‘adc_value’:

Full Arduino code:

The following video shows a simple hardware circuit of this project:

and the one below shows Proteus simulation (simulation circuit is not the same as real hardware circuit, example circuit diagram is shown above):

Proteus simulation file download:
Arduino ADC 7-segment display

3 comments

  1. Arduino UNO board and 6 or 4-Digit common anode 7-segment display using clock .
    circuit and program available

  2. Can it be translated to another range/scale of value?
    For example, I’d like to have a range/scale between 0.0 up to 2.0 min to max (or 0.000 to 2.000), meanwhile range of this project is 0000 up to 1023. What code to be changed?
    Thank you

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.