# About Processing's serial port

**URL:** <https://discourse.processing.org/t/about-processings-serial-port/21432>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [May 30, 2020, 6:31pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432 "2020-05-30T18:31:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 6:31pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/1 "2020-05-30T18:31:21Z")

</div>

Hi there It’s me again so Here is a photo about the issue.

 ![SA](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/ab8f6d1e01a5cb14710efd2aa29af1887bfc6f79.png) . So as you can see (here is the code btw

```auto
import processing.serial.*;  
import controlP5.*;
/////////////////
int interval = 0;
int end = 10;   
String receivedString;   
Serial myPort; 
ControlP5 cp5;
Chart XChart;
Chart YChart;
Chart ZChart;
Chart GXChart;
Chart GYChart;
Chart GZChart;
Chart TempChart;
Chart AChart;
Chart BChart;
Chart CChart;
/////////////////
void setup() {
/////////////////
size(1920 , 1080);
background(#F5E6E6);
smooth();
strokeWeight(3);
textSize(16);
/////////////////
myPort= new Serial(this, Serial.list()[0], 115200); 
myPort.clear();  
receivedString = myPort.readStringUntil(end);
cp5 = new ControlP5(this); 
/////////////////
receivedString = null; 
//
XChart = cp5.addChart("X Ekseni")
.setPosition(5, 0)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//         
YChart = cp5.addChart("Y Ekseni")
.setPosition(485, 0)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//               
ZChart = cp5.addChart("Z Ekseni")
.setPosition(965, 0)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//            
GXChart = cp5.addChart("GX Ekseni")
.setPosition(1445, 0)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//
GYChart = cp5.addChart("GY Ekseni")
.setPosition(5, 365)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//               
GZChart = cp5.addChart("GZ Ekseni")
.setPosition(5, 725)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//      
TempChart = cp5.addChart("Sıcaklık")
.setPosition(1445, 365)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//       
AChart = cp5.addChart("Degisik")
.setPosition(485, 725)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//
BChart = cp5.addChart("Farklı")
.setPosition(965, 725)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//              
CChart = cp5.addChart("ASD")
.setPosition(1445, 725)
.setSize(470, 280)
.setRange(-30, 400)
.setView(Chart.LINE) 
.setStrokeWeight(1.5)
.setColorCaptionLabel(color(40));
//
AChart.addDataSet("incoming");
AChart.setData("incoming", new float[100]);
//
BChart.addDataSet("incoming");
BChart.setData("incoming", new float[100]);
//
CChart.addDataSet("incoming");
CChart.setData("incoming", new float[100]);
//                 
TempChart.addDataSet("incoming");
TempChart.setData("incoming", new float[100]);
//                 
GYChart.addDataSet("incoming");
GYChart.setData("incoming", new float[100]);
//
GZChart.addDataSet("incoming");
GZChart.setData("incoming", new float[100]);
//             
XChart.addDataSet("incoming");
XChart.setData("incoming", new float[100]);
//  
YChart.addDataSet("incoming");
YChart.setData("incoming", new float[100]);
//  
ZChart.addDataSet("incoming");
ZChart.setData("incoming", new float[100]);
//
GXChart.addDataSet("incoming");
GXChart.setData("incoming", new float[100]);
//  
delay(1000);
myPort.write('r');
delay(10000);
myPort.clear();
delay(10000);
myPort.clear();
delay(10000);
//////////////////////////End of the Setup void.
}
void draw(){
  while (myPort.available () > 0){ 
receivedString = myPort.readStringUntil(end);
}
if (receivedString != null)
{  
String[] a = split(receivedString, ',');
float[] f = new float[a.length]; 
int[] v = new int[a.length];
for(int i = 0; i < a.length; i++)
{
  f[i] = Float.parseFloat(a[i].trim());
  v[i] = round((float)f[i]);
  println(f[i] + "\t\t" + v[i]);

//Defining what will charts push.(Value)
XChart.push("incoming",v[0]);
YChart.push("incoming",v[1]);
ZChart.push("incoming",v[2]);
GXChart.push("incoming",v[3]);
GYChart.push("incoming",v[4]);
GZChart.push("incoming",v[5]);
AChart.push("incoming",v[6]);
BChart.push("incoming",v[7]);
CChart.push("incoming",v[8]);
TempChart.push("incoming",v[9]);
//Line codes
stroke(#000000);
line(480,0,480,1080);
line(960,360,960,0);
line(960,720,960,1080);
line(1440,0,1440,1080);
line(0,360,1920,360);
line(0,720,1920,720);  
//X Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(180,300,100,50,10);
fill(#FF301E);
text(f[0],200,330);
fill(#FFFFFF);
//Y Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(660,300,100,50,10);
fill(#FF301E);
text(f[1],680,330);
fill(#FFFFFF);
//Z Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(1140,300,100,50,10);
fill(#FF301E);
text(f[2],1160,330);
fill(#FFFFFF);
//GX Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(1620,300,100,50,10);
fill(#FF301E);
text(f[3],1640,330);
fill(#FFFFFF);
//GY Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(180,660,100,50,10);
fill(#FF301E);
text(f[4],200,690);
fill(#FFFFFF);
//GZ Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(1620,660,100,50,10);
fill(#FF301E);
text(f[5],1640,690);
fill(#FFFFFF);
//A Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(180,1020,100,50,10);
fill(#FF301E);
text(f[6],200,1050);
fill(#FFFFFF);
//B Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(660,1020,100,50,10);
fill(#FF301E);
text(f[7],680,1050);
fill(#FFFFFF);
//C Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(1140,1020,100,50,10);
fill(#FF301E);
text(f[8],1160,1050);
fill(#FFFFFF);
//Temp Chart Value
fill(#D6C0C0);
stroke(#000000);
rect(1620,1020,100,50,10);
fill(#FF301E);
text(f[9],1640,1050);
fill(#FFFFFF);
}
}
}

```

)  
There is nothing wrong about this code but it does not work when I try to run it. If there is a way to solve this plz write down thanks

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 30, 2020, 6:36pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/2 "2020-05-30T18:36:13Z")

</div>

Hello,

Please format your code as a courtesy to the community:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

Try to cut and paste it and you will see why.

I won’t look at it as is.

`:)`

---

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 6:42pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/3 "2020-05-30T18:42:49Z")

</div>

Okay,sure I’ll do it

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 30, 2020, 8:38pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/4 "2020-05-30T20:38:02Z")

</div>

Hello,

What is sending the data?

I substituted some test data:

```auto
receivedString = "0,100,2,30,4,50,6,70,8,90,10";
if (receivedString != null)

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a734f64899c6ec216e95bb41759aa6e1236fd39a.png)

That is all I can offer without knowing more.

Try adding:  
[https://processing.org/reference/libraries/serial/Serial\_list\_.html](https://processing.org/reference/libraries/serial/Serial_list_.html)

And make sure you are connected to the correct serial port.

Your formatting made this easy to copy.

`:)`

---

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 8:39pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/5 "2020-05-30T20:39:54Z")

</div>

Yes I tried to send some numbers into it now. And It worked. But When I actually try to get some numbers from arduino It just doesnt work it gets stuck everytime I try to send numbers from arduino

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 30, 2020, 8:41pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/6 "2020-05-30T20:41:35Z")

</div>

Write some very simple Arduino code to send test data and share that and I will try it.

Keep it simple.

`:)`

---

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 8:44pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/7 "2020-05-30T20:44:09Z")

</div>

```auto
  void setup() {
  Serial.begin(115200);
  }
  
  void loop() {
  Serial.print("756.34");
  Serial.print(",");
  Serial.print("354.45");
  Serial.print(",");
  Serial.print("87.98);
  }

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 30, 2020, 8:53pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/8 "2020-05-30T20:53:41Z")

</div>

You are not sending an ‘end’ from Arduino.

`receivedString = myPort.readStringUntil(end);`

You need to send this on Arduino side.

[https://www.arduino.cc/reference/en/language/functions/communication/serial/println](https://www.arduino.cc/reference/en/language/functions/communication/serial/println)

`:)`

---

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 9:25pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/9 "2020-05-30T21:25:15Z")

</div>

So you mean If I just put Serial.println(" "); It will solve the problem

---

<div class="post-metadata">

**Author:** ![SouSageYa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sousageya/32/9819_2.png) [@SouSageYa](https://discourse.processing.org/u/SouSageYa)\
**Post date:** [May 30, 2020, 9:26pm UTC](https://discourse.processing.org/t/about-processings-serial-port/21432/10 "2020-05-30T21:26:30Z")

</div>

Thx man I appreciate it very much thx for all again. Much love from Turkey
