// textplot - four analog input devices

int potentiometer[] = {A0, A1, A2, A3}; // define analog inputs
int arraySize = sizeof(potentiometer) / sizeof(potentiometer[0]); // number of analog inuts

#define DELAY   100     // delay between analog read
#define MININ   0       // analog input minimum value
#define MAXIN   1023    // analog input maximum balue
#define MINOUT  0       // analog input re-mapped minimum value 
#define MAXOUT  15      // analog input re-mapped maximum value

void setup() {
  Serial.begin(115200); // start serial monitor
  for (int i = 0; i < arraySize; i++)
    pinMode(potentiometer[i], INPUT); // configure analog input pin
}

void loop() {
  for (int i = 0; i < arraySize; i++) {
    int pinReading = analogRead(potentiometer[i]); // read analog input pin
    int outputValue = (map(pinReading, MININ, MAXIN, MINOUT, MAXOUT));  // map analog input to plotable range

    if (i == 0)
      Serial.print("|"); // start marker
    Serial.print(i);
    Serial.print("=");
    spacePad(pinReading); // format analog reading
    Serial.print(pinReading);
    Serial.print("|");

    // plot the data by mapping output to spaces
    for (int i = 0; i < outputValue; i++)
      Serial.print(" ");
    Serial.print("*");

    // add a gap before next plot trace
    for (int i = 0; i < MAXOUT - outputValue; i++)
      Serial.print(" ");
    Serial.print("|"); // end marker
  }
  Serial.println(); // newline at end of plot line
  delay(DELAY); // keep output from running off the monitor
}

void spacePad (int outVal) { // format output value for Serial Monitor
  for (int i = 1000; i > 1; i /= 10) // divide by 10
    if (outVal < i) // if within this order
      Serial.print("_"); // pad
}