How to connect a potentiometer with an arduino and display its values onto a 4-7 segment displays (values from 0 - 1023)

I use the software Tinkercad so any help would be useful :slight_smile:

Try the Tinkercad forum. This is the Arduino forum.

Why did you post this in the Covid 19 section of the forum ?

Your post was MOVED to its current location as it is more suitable.

oh alright :))))))

It seemed like a good idea at the time? :crazy_face:

It also must have seemed like a good idea to post a duplicate, which is what @homerprogrammer just did

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Exactly which 7-segment display do you have? Is it four individual digits with 8, 9, or 10 pins each? Is it four digits in a unit with 11, 12, or 13 pins? Are the digit pins Anodes (+) or Cathodes (-). Are the displays on a board with a driver chip? How are the pins on the board labeled?

they are 4 separate 7 segment display, have a common anode and are connected to pins 10,11,12,13
any help in the programming part would be useful

// Bit maps for the seven segment display

// Segment Cathodes (0/LOW for on, 1/HIGH for off)
const byte Segments[] =
{
  0b11000000, // 0
  0b11001111, // 1
  0b10100100, // 2
  0b10000110, // 3
  0b10001011, // 4
  0b10010010, // 5
  0b10010000, // 6
  0b11000111, // 7
  0b10000000, // 8
  0b10000011, // 9
};


// List of digit select lines, least significant digit first
// Digit Common Anodes (HIGH for on, LOW for off)
const byte DigitCount = 4;
const byte DigitPins[DigitCount] = {10, 11, 12, 13};

// Segment Cathodes (LOW for on, HIGH for off)
const byte SegmentCount = 7;
const unsigned char SegmentPins[SegmentCount] = {3, 4, 5, 6, 7, 8, 9};

void setup()
{
  for (int i = 0; i < DigitCount; i++)
  {
    pinMode(DigitPins[i], OUTPUT);
    digitalWrite(DigitPins[i], LOW);
  }

  for (int i = 0; i < SegmentCount; i++)
  {
    pinMode(SegmentPins[i], OUTPUT);
    digitalWrite(SegmentPins[i], HIGH);
  }
}

void loop()
{
  int value = 9999;

  // Clear all segments before enabling a digit
  for (int s = 0; s < SegmentCount; s++)
  {
    digitalWrite(SegmentPins[s], HIGH);
  }

  // Display each digit, right to left
  for (int i = 0; i < DigitCount; i++)
  {
    // Peel a digit off the low end of the number
    int digit = value % 10;
    value /= 10;

    // Blank the MSD if it is zero
    if (i == 3 && digit == 0)
    {
      for (int s = 0; s < SegmentCount; s++)
        digitalWrite(SegmentPins[s], HIGH);
    }
    else
    {
      // Display the digit on the seven segments
      unsigned char segments = Segments[digit];
      for (int s = 0; s < SegmentCount; s++)
      {
        digitalWrite(SegmentPins[s], segments & 1);
        segments >>= 1;
      }
    }

    // Turn on the digit briefly
    digitalWrite(DigitPins[i], HIGH);  // Select one digit
    delayMicroseconds(3000UL);  // Higher numbers give higher brightness but more flicker
    digitalWrite(DigitPins[i], LOW);
  }
}


it just shows 1 1 1 1 on the 4-7 segment displays,
my main purpose is to show the potentiometer values (0-1023) on the 4 digit 7 segment displays
any help would be nice

Change:
int value = 9999;
to
int value = analogRead(A0);


it shows this now :((
and when i turn the potentiometer it doesn't do anything
could u look at the wiring idk if there is a mistake but still?
thank you

Give us a link to the display.

Give us a link to the display data sheet.

Maybe you were wrong when you said "common anode". Try changing:

    // Turn on the digit briefly
    digitalWrite(DigitPins[i], HIGH);  // Select one digit
    delayMicroseconds(3000UL);  // Higher numbers give higher brightness but more flicker
    digitalWrite(DigitPins[i], LOW);

to:

    // Turn on the digit briefly
    digitalWrite(DigitPins[i], LOW);  // Select one digit
    delayMicroseconds(3000UL);  // Higher numbers give higher brightness but more flicker
    digitalWrite(DigitPins[i], HIGH);

You should be wiring the displays similar to this.

Each segment needs a resistor.

Each digit needs a driver.

image

here is the link, for it, could you please make adjustments to it?


still is not showing values from 0-1023

try the link maybe?


i brought the potentiometer down from the breadboard and it shows some digits but not completely, can you tell me why is this happening?

also this is the link if you could make changes to the code and the circuit

I would try reversing the order of the first 7 segment pins:

const unsigned char SegmentPins[SegmentCount] = {8, 7, 6, 5, 4, 3, 2, 9};


it workedd!! but i dont know why the numbers are upside down or in reverse????
i think we are very close :)))