Pages: [1]   Go Down
Author Topic: temperature sensor  (Read 360 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}


Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33966
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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??
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26219
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you read this?
Why not?

Code:
Serial.println((byte)tempE);
Quote
.the other 4 comes below one another
http://arduino.cc/en/Serial/Println
« Last Edit: March 15, 2013, 05:05:57 pm by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: