Hallo, ich habe folgende Sketches:
Processing:
//import Serial communication library
import processing.serial.*;
//init variables
Serial commPort;
float tempX;
void setup()
{
commPort = new Serial(this, "COM3", 9600);
}
void draw()
{
//get the temp from the serial port
while (commPort.available() > 0)
{
tempX = commPort.read();
tempX=int(tempX);
println(tempX);
}
}
Arduino:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define LCD_CLEAR 0b00000001 // 0×01
float temp;
int tempPin = 0;
int testX;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
//lcd.print("");
}
void loop() {
temp = analogRead(tempPin);
temp = temp * 0.48828125;
lcd.setCursor(0, 0);
lcd.print(temp);
lcd.print(" C");
delay(1000);
lcd.clear();
testX=int(temp);
Serial.print(temp);
Serial.print(testX); //send the data to the computer
delay(1000);
//Serial.println(temp);
}
Wenn ich den Sketch auf mein Board hochlade und den Seriellen Monitor anhabe, werden mir Werte zwischen 21 und 23 (was auch hinkommt).
Schalte ich den seriellen Monitor aus und starte den Processing Sketch werden mir aber plötzlich Werte zwischen 50 und 52 angezeigt.
Kann mir jemand helfen?