hello everybody I ma facing problem with arduino code i want to analyze 5 different values from 5 analog pins and i want to see the data as in 5 column shape not in one ! please any help i will be grateful for you
here is my code
void setup() {
Serial.begin(9600);
}
void loop()
{
int analogValue1 = analogRead(A0);
Serial.print("analogValue1=");
Serial.println(analogValue1);
delay(100);
int analogValue2 = analogRead(A1);
Serial.print("analogValue2=");
Serial.println(analogValue2);
delay(100);
int analogValue3 = analogRead(A2);
Serial.print("analogValue3=");
Serial.println(analogValue3);
delay(100);
int analogValue4 = analogRead(A3);
Serial.print("analogValue4=");
Serial.println(analogValue4);
delay(100);
int analogValue5 = analogRead(A4);
Serial.print("analogValue5=");
Serial.println(analogValue5);
delay(100);
}
serial moitor of 5 analog pins.ino (651 Bytes)
Hint: How many times do you want to print the headings ( Serial.print("analogValue1="); )?
Second hint. Do these prints appear on the same line?:
Serial.print("analogValue1=");
Serial.println(analogValue1);
Why?
i want to see the data as in 5 column shape not in one !
You should read the tutorial about array's
but that said here is some variation that does columns
int count = 0;
void setup()
{
Serial.begin(9600);
Serial.println(__FILE__);
}
void loop()
{
if (count % 20 == 0) // every 20 lines a header
{
Serial.println();
Serial.println("AV1 \tAV2 \tAV3 \tAV4 \tAV5");
}
count++;
int analogValue0 = analogRead(A0);
Serial.print(analogValue0);
Serial.print("\t");
int analogValue1 = analogRead(A1);
Serial.print(analogValue1);
Serial.print("\t");
int analogValue2 = analogRead(A2);
Serial.print(analogValue2);
Serial.print("\t");
int analogValue3 = analogRead(A3);
Serial.print(analogValue3);
Serial.print("\t");
int analogValue4 = analogRead(A4);
Serial.print(analogValue4);
Serial.print("\t");
Serial.println();
delay(1000);
}
thank you so much robtillaart it works perfectly