Hi , im working on a telemetry project but i stucked.In theory everything is ok but in practice nothing happens.Program dont draw the graph.I just write the code for temp. sensor to try and used gwoptics library it doesnt matter i stucked in Serial event here is the code.Datas come from arduino with serial port and im reading this datas but i need graph.I will be very pleasure if you help me to draw the graph of temp. data.
- import org.gwoptics.graphics.graph2D.Graph2D;
import org.gwoptics.graphics.graph2D.LabelPos;
import org.gwoptics.graphics.graph2D.traces.Line2DTrace;
import org.gwoptics.graphics.graph2D.traces.ILine2DEquation;
import processing.serial.*;
Graph2D g1, g2 ;
Serial arduino ;
float tempXyer = 960; //sicaklik grafiginin başlama noktasi x ekseninde
PrintWriter sicaklik ;
void setup()
{
size(1300, 700);
//seri port tanimlaniyor
println(Serial.list());
arduino = new Serial(this, Serial.list()[1], 9600);
arduino.bufferUntil('\n');
//grafik boyutu ve grafik tanımlanıyor
g1 = new Graph2D(this, 400, 250, false);
g2 = new Graph2D(this, 300, 250, false) ;
//sicaklik için database oluşturma
sicaklik = createWriter("sicaklik.txt") ;
//grafik özellikleri
g1.setYAxisMin(0);
g1.setYAxisMax(160);
g1.setXAxisMin(0);
g1.setXAxisMax(300);
g1.setXAxisLabel("Zaman (s)");
g1.setYAxisLabel("Hız (Km/h)");
g1.setXAxisTickSpacing(50);
g1.setYAxisTickSpacing(10);
g1.position.x = 70 ;
g1.position.y = 30 ;
g2.setYAxisMin(0);
//2. grafik
g2.setYAxisMax(50);
g2.setXAxisMin(0);
g2.setXAxisMax(300);
g2.setXAxisLabel("Zaman (s) ");
g2.setYAxisLabel("Sıcaklık (°C)");
g2.setXAxisTickSpacing(50);
g2.setYAxisTickSpacing(10);
g2.position.x = 960 ;
g2.position.y = 30 ;
ellipseMode(CENTER);
}
void draw()
{
background(255) ;
g1.draw() ;
//g2.draw();
stroke(0);
ellipse(580, 175, 200, 200);
ellipse(790, 175, 200, 200);
}
void serialEvent(Serial arduino)
{
String myString = arduino.readStringUntil('\n') ;
if ( myString != null)
{
myString = trim(myString) ;
//println(myString);
float isi = float(myString) ;
isi *= 5 ;
//sicaklik grafigi
stroke(0);
line(tempXyer, 280, tempXyer, 280-isi);
}
//sicaklik.txt e veriler depolaniyor
sicaklik.println("Zaman :"+hour()+":"+minute()+":"+second()+" Sicaklik :" + myString);
sicaklik.flush();
if (tempXyer >= 1260 )
{
tempXyer=960;
background(255);
}
else {
tempXyer++ ;
}
}
1