# 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:** 6\
**Page:** 1

<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 4, 2020, 11:14pm UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/1 "2020-05-04T23:14:29Z")

</div>

i am a beginner I would appreciate it if someone help me to write a programme to receive data(62 data) from arduino to processing and class them in a table plz

---

<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 4, 2020, 11:42pm UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/2 "2020-05-04T23:42:22Z")

</div>

Hello,

> [@MaissaHamdi](#):
>
> help me to write a programme to receive data(62 data) from arduino to processing

What is your your progress so far?  
What kind of data?

Get to know the resources available to you.

> **Resources \< Click here to expand !**
>
> I encourage you to review the resources available here:
> 
> - The Processing website has references, examples, tutorials, etc.  
> [https://processing.org/](https://processing.org/)
> - Those available with the Processing PDE (IDE).  
> An exploration of the tabs will reveal what is available; there are libraries and examples there.
> - The Coding Train  
> [https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
> [https://thecodingtrain.com/](https://thecodingtrain.com/)
> - Happy Coding  
> [Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)
> - The Processing Foundation  
> [https://processingfoundation.org/](https://processingfoundation.org/)  
> Check out the tabs.  
> In the education tab, there is a reference to the Coding Train.

Related:

> **[Serial / Libraries](https://processing.org/reference/libraries/serial/index.html)**
>
> Send data between Processing and external hardware through serial communication (RS-232).

[https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all](https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all)

> **[Table / Reference](https://processing.org/reference/table)**
>
> Table objects store data with multiple rows and columns, much like in a traditional spreadsheet. Tables can be generated from scratch, dynamically, or using data from an existing file. Tables c…

`:)`

---

<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 4, 2020, 11:50pm UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/3 "2020-05-04T23:50:43Z")

</div>

I am looking for a way to recieve sensor data from arduino to processing and class those data in table in the same order that I recieved them so I can draw graphes with them and display them

---

<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:29am UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/4 "2020-05-05T00:29:16Z")

</div>

@glv I already got the recieving part I juste need to class my data in a table in processing  
this is my sending from arduino programme

```auto
void setup() {
 
  Serial.begin(9600);
}
void loop() {
  Serial.print(analogRead(A0));
  Serial.print("\n");
  Serial.print(analogRead(A1));
  Serial.print("\n");
  Serial.print(analogRead(A2));
  Serial.print("\n"); 
  delay(500);
}

```

---

<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 5, 2020, 12:40am UTC](https://discourse.processing.org/t/data-communication-from-arduino-processing-post-1/20482/5 "2020-05-05T00:40:41Z")

</div>

Hello,

> [@MaissaHamdi](#):
>
> I juste need to class my data in a table in processing

What have you done so far?

> **[class / Reference](https://processing.org/reference/class.html)**
>
> Keyword used to indicate the declaration of a class. A class is a composite of fields (data) and methods (functions that are a part of the class) which may be instantiated as objects. The first lette…

> **[Table / Reference](https://processing.org/reference/Table.html)**
>
> Table objects store data with multiple rows and columns, much like in a traditional spreadsheet. Tables can be generated from scratch, dynamically, or using data from an existing file. Tables c…

`:)`

---

<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; 
  }
}

```
