# How to create data array?

**URL:** <https://discourse.processing.org/t/how-to-create-data-array/41094>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [February 28, 2023, 6:37pm UTC](https://discourse.processing.org/t/how-to-create-data-array/41094 "2023-02-28T18:37:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vadimkuzmin](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@Vadimkuzmin](https://discourse.processing.org/u/Vadimkuzmin)\
**Post date:** [February 28, 2023, 6:37pm UTC](https://discourse.processing.org/t/how-to-create-data-array/41094/1 "2023-02-28T18:37:54Z")

</div>

How can I create an array of data to send to the com port from this example?

> **[Handles / Examples](https://processing.org/examples/handles.html)**
>
> Click and drag the white boxes to change their position.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [February 28, 2023, 7:02pm UTC](https://discourse.processing.org/t/how-to-create-data-array/41094/2 "2023-02-28T19:02:40Z")

</div>

Hi @Vadimkuzmin,

Guess the only relevant data is the stretch value of the handles. So collect them to an array and send it via com port. Maybe you can add an id to it to be able to distinguish the different values …  
To send and receive data you can use

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

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [March 2, 2023, 11:20am UTC](https://discourse.processing.org/t/how-to-create-data-array/41094/3 "2023-03-02T11:20:13Z")

</div>

Collecting into an array, sending, reading (in the Arduino) provokes several questions or decisions about what to do. Send the whole set each time? Or Send one each time it changes (with the ident of which one that was.) Send as text or binary? How to identify the start and end of messages? The examples given with the Serial library don’t tell you how to send multi-values. To get quickly past all this I wrote an [example](https://discourse.processing.org/t/processing-and-arduino-serial-example/31650), which will almost certainly work first time. One way forward is to run that, then substitute your own data.
