int readPin=A4;
int V2=0;
int oldV2=0;
//int delayTime=500; //No longer needed
int potMax=1024;
int grLen=32;
int GR=potMax/grLen;
void setup() {
pinMode(readPin, INPUT);
Serial.begin(9600);
}
void loop() {
V2=analogRead(readPin);
if(V2!=oldV2) { //Check if V2 has changed, if not, skip ahead
oldV2=V2; //V2 has changed. Set new value.
Serial.print("|"); //print a nice graph to show POT position
GR=V2*grLen/potMax;
for(int i=0;i<=GR;i++){ //spaces before *
Serial.print(" ");
}
Serial.print("*");
for(int i=GR;i<=grLen;i++){ //spaces after *
Serial.print(" ");
}
Serial.print("| "); //right edge of graph
Serial.print(V2);
if(V2<1000){Serial.print(" ");}//pad out to align Time:
if(V2<100){Serial.print(" ");}
if(V2<10){Serial.print(" ");}
Serial.print(" Time:");
Serial.print(millis());
Serial.println();
}
//delay(delayTime); //No longer needed
}