We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › arduino to processing. 2 temps varying values
Page Index Toggle Pages: 1
arduino to processing. 2 temps varying values (Read 792 times)
arduino to processing. 2 temps varying values
Aug 22nd, 2009, 6:56pm
 
I have 2 thermocouples hooked up to my arduino.  I have the temps displaying properly in my sketch but one of the temps, always tempEnvF  on any analogue.  So I'm figuring its a coding issue.  About every 10 seconds, it reads 30 deg F.

Arduino Code
Code:
//declare variables
float tempC;
float tempB;
int beanPin = 0;
int envPin = 1;

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
}

void loop()
{
tempC = analogRead(beanPin);           //read the value from bean sensor
tempB = analogRead(envPin);           //read value from environment sensor
tempC = (5.0 * tempC * 100.0)/1024.0;  //convert bean analog data to temperature
tempB = (5.0 * tempB * 100.0)/1024.0;  //convert env analog data to temp
Serial.print((byte)tempC);             //send the data to the computer
Serial.print((byte)tempB);
delay(1000);                           //wait one second before sending new data
}


processing.
Code:
void setup()
{
 
 commPort = new Serial(this, Serial.list()[1], 9600);
 
 size(500,375);
 background(255);
}
void draw()
{
while (commPort.available() > 0)
 {
   tempC = commPort.read();
   tempB = commPort.read();
 
  tempF = ((tempC*9)/5) + 32;
  tempEnvF = ((tempB*9)/5) + 32;
 
 }
void showtemp()
{
fill(0,0,0);
textFont(font24);
textAlign(LEFT);
text(str((int)tempF) + " F", 335, 85);
text(str((int)tempEnvF) + " F", 435,85);
}


Page Index Toggle Pages: 1