# Data communication from Arduino/Processing Post #1

**URL:** <https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [May 4, 2020, 11:14pm UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482 "2020-05-04T23:14:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![MaissaHamdi](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@MaissaHamdi](https://discourse.processing.org/u/MaissaHamdi)\
**Post date:** [May 5, 2020, 12:53am UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/6 "2020-05-05T00:53:18Z")

</div>

Hi, Thanks for the suggestion,  
I did an application where I recieved my data from the arduino and decplayed them in graph  
now I just need put the data that I recieved in tabular in processing  
this is what I did

```auto
//Variables to draw a continuous line.
int lastxPos=1;
int lastheight=0;

void setup () {
  // set the window size:
  size(600, 400);        

  myPort = new Serial(this, "COM5", 9600);  

  // A serialEvent() is generated when a newline character is received :
  myPort.bufferUntil('\n');
  background(0); // set inital background:
}
void draw () {
  if (newData) {
    //Drawing a line from Last inByte to the new one.
    stroke(127,34,255); //stroke color
    strokeWeight(4); //stroke wider
    line(lastxPos, lastheight, xPos, height - inByte); 
    lastxPos= xPos;
    lastheight= int(height-inByte);

    // at the edge of the window, go back to the beginning:
    if (xPos >= width) {
      xPos = 0;
      lastxPos= 0;
      background(0); //Clear the screen.
    } 
    else {
      // increment the horizontal position:
      xPos++;
    }
   newData =false;
 }
}

void serialEvent (Serial myPort) {
  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');
  if (inString != null) {
    inString = trim(inString); // trim off whitespaces.
    inByte = float(inString); // convert to a number.
    inByte = map(inByte, 0, 1023, 0, height); //map to the screen height.
    newData = true; 
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482)._
