Go Down

Topic: temperature sensor (Read 402 times) previous topic - next topic

kailash

im using 8 temperature sensors and i run the following sketch..but im not able to get my result in a column series...that happens only for the first 4 reading...the other 4 comes below one another..CAN SOMEONE HELP ME??
//Declare variables


float tempA;//0
float tempB;//1
float tempC;//2
float tempD;//3
float tempE;//4
float tempF;//5
float tempG;//6
float tempH;//7


int tempAPin = 0;
int tempBPin = 1;
int tempCPin = 2;
int tempDPin = 3;
int tempEPin = 4;
int tempFPin = 5;
int tempGPin = 6;
int tempHPin = 7;// Temp sensor plugged analog pin 0




// Write setup function

void setup ()
{
 
Serial.begin(9600); //Opens serial port to communicate with temp sensor
Serial.println("t1\t2\t3\t4\t5\t6\t7\t8");
}

// Write loop that will control what we want the arduino to do with the sensor readout
void loop ()
{

tempA = analogRead(tempAPin);
tempA = (5.0*tempA*100.0)/1024.0;
Serial.print((byte)tempA);
Serial.print("\t" );

tempB = analogRead(tempBPin);
tempB = (5.0*tempB*100.0)/1024.0;
Serial.print((byte)tempB);
Serial.print("\t" );

tempC = analogRead(tempCPin);
tempC = (5.0*tempC*100.0)/1024.0;
Serial.print((byte)tempC);
Serial.print("\t" );


tempD = analogRead(tempDPin);
tempD = (5.0*tempD*100.0)/1024.0;
Serial.print((byte)tempD);
Serial.println("\t");

tempE = analogRead(tempEPin);
tempE = (5.0*tempE*100.0)/1024.0;
Serial.println((byte)tempE);
Serial.println("\t");

tempF = analogRead(tempFPin);
tempF = (5.0*tempF*100.0)/1024.0;
Serial.println((byte)tempF);
Serial.println("\t");

tempG = analogRead(tempGPin);
tempG = (5.0*tempG*100.0)/1024.0;
Serial.println((byte)tempG);
Serial.println("\t");

tempH = analogRead(tempHPin);
tempH = (5.0*tempH*100.0)/1024.0;
Serial.println((byte)tempH);
Serial.println("\t");

Serial.println(" ");

delay(1000);
}



Grumpy_Mike

Quote
but im not able to get my result in a column series

This is a micro controller rather than a computer so most of the code for making the output look pretty has been removed. It is all in C so you can put it back and use printf if you like by including the stdio module.
Otherwise you can mess about with tabs, or looking at the length of strings and adding extra spaces to make things line up.
However, is it that important?

kailash

thanks mike ,it is important.. and im quite new to arduino and i know nothing about c...so could u please tell me what exactly im supposed to change??

AWOL

#3
Mar 15, 2013, 10:49 pm Last Edit: Mar 15, 2013, 11:05 pm by AWOL Reason: 1
Did you read this?
Why not?

Code: [Select]
Serial.println((byte)tempE);
Quote
.the other 4 comes below one another

http://arduino.cc/en/Serial/Println
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

kailash

sorry about that...thanks for the suggestion...i will try it

kailash

sorry about that...dint notice ...thanks a lot again

Go Up