Potentiometer + Screen, How to only show active Pot

Im doing a project, with 5 potentiometers connected to a OLED 128x64 Screen.

I manage to show all 5 Pot % on the screen, but i want Only to show the active potentiometer, meaning the one I'm touching.
how can i hide everything, but the active one?

Pic. https://i.imgur.com/CdR3Jw0.png

#include <SPI.h>               
#include <Wire.h>              
#include <Adafruit_GFX.h>     
#include <Adafruit_SSD1306.h>  
#define POTENTIOMETER_PIN A0
#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);





const int NUM_SLIDERS = 5;
const int analogInputs[NUM_SLIDERS] = { A0, A1, A2, A3, A4 };

int level = 0;
int level1 = 0;
int level2 = 0;
int level3 = 0;
int level4 = 0;
int PotValue;
int analogSliderValues[NUM_SLIDERS];


void setup() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    pinMode(analogInputs[i], INPUT);
  }

  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);  
  display.display();                         
  delay(2000);                                
  display.clearDisplay();                   
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
}

void loop() {




  level = (analogRead(A0));
  level1 = (analogRead(A1));
  level2 = (analogRead(A2));
  level3 = (analogRead(A3));
  level4 = (analogRead(A4));




  delay(100);
  int level = analogRead(A0);
  int percentage = map(level, 0, 1023, 0, 100);
  int percentage1 = map(level1, 0, 1023, 0, 100);
  int percentage2 = map(level2, 0, 1023, 0, 100);
  int percentage3 = map(level3, 0, 1023, 0, 100);
  int percentage4 = map(level4, 0, 1023, 0, 100);

  display.clearDisplay();
  display.setCursor(1, 1);
  display.setTextSize(1); 
  display.setTextColor(WHITE);
  display.print("Potentiometer at ");
  display.print(percentage);
  display.println("%");
  display.print("Potentiometer at ");
  display.print(percentage1);
  display.println("%");
  display.print("Potentiometer at ");
  display.print(percentage2);
  display.println("%");
  display.print("Potentiometer at ");
  display.print(percentage3);
  display.println("%");
  display.print("Potentiometer at ");
  display.print(percentage4);
  display.println("%");





  display.display();
  updateSliderValues();
  sendSliderValues();  
 
  delay(10);
}

void updateSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    analogSliderValues[i] = analogRead(analogInputs[i]);
  }
}

void sendSliderValues() {
  String builtString = String("");

  for (int i = 0; i < NUM_SLIDERS; i++) {
    builtString += String((int)analogSliderValues[i]);

    if (i < NUM_SLIDERS - 1) {
      builtString += String("|");
    }
  }

  Serial.println(builtString);
}

void printSliderValues() {
  for (int i = 0; i < NUM_SLIDERS; i++) {
    String printedString = String("Slider #") + String(i + 1) + String(": ") + String(analogSliderValues[i]) + String(" mV");
    Serial.write(printedString.c_str());

    if (i < NUM_SLIDERS - 1) {
      Serial.write(" | ");
    } else {
      Serial.write("\n");
    }
  }
}

how do you think you would recognize the one you're "touching"? (or do you mean changing)

once you know that it should be easy, right?

yes, changing it, just turning the potentiometer.

i have it working, just want to show 1 at the time, the one I'm moving.

you have it working ? what's the problem?

That i want to show only 1 at time "Potentiometer X at %" instead of all Pot on the screen.

you've said this a few times, but haven't explained what is so difficult.

surely you can just change the prints to display which pot and it's value that is changing.

you should be able to monitor each pot value, compare it to the last to see which pot is changing the then display the pot and value

what do you need help with?

the problem is that i dont know how to do that. my code is a mesh of lots of thing i found. but thanks anyway.

do what

  • determine which pot is changing?
  • display the pot and value for just one pot?
  • determine which pot is changing to then display that.

consider


const byte PotPins [] = { A0, A1, A2, A3 };
#define Npots   sizeof(PotPins)

int potVals [Npots];

void
loop (void)
{
    for (unsigned n = 0; n < Npots; n++)  {
        int val = analogRead (PotPins [n]);
        if (abs (potVals [n] - val) > 5)  {
            potVals [n] = val;

            Serial.print (n);
            Serial.print ("  ");
            Serial.println (val);
        }
    }
    delay (500);
}

void
setup (void)
{
    Serial.begin (9600);

    for (unsigned n = 0; n < Npots; n++)
        potVals [n] = analogRead (PotPins [n]);
}

ok, i will work with that.
Thanks

seems to be working, just finishing some details, for example, can you adapt the potentiometer 0-1023 to a 0-100?
before this new code, i have something like this.

int level = analogRead(A0);
int percentage = map(level, 0, 1023, 0, 100);

but not longer works

guessing you're doing this before the comparison. why not do the mapping just before printing?

and in this code, is possible to change the Serial.print (n) to show a custom text instead of just showing a number?

of course.
you can modify and add prints for anything you'd like