# How do I use Processing to read and write data to an Arduino

**URL:** https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113
**Category:** Electronics (Arduino, etc.)
**Created:** [May 20, 2020, 7:58pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113 "2020-05-20T19:58:23Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [May 20, 2020, 7:58pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/1 "2020-05-20T19:58:23Z")

</div>

Looking for a front end to manage Arduino data from a PC.  
I Know the arduino side (Serial IO and parsing), looking for a PC side option.  
The need is to read data from the arduino, make changes, and write updated data back to arduino.  
Actual task is managing EEE memory configuration data.

Looking for examples of user interaction, such as creating entry form with text display and input, pick lists, etc.

---

<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 20, 2020, 8:17pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/2 "2020-05-20T20:17:48Z")

</div>

Hello,

Here are some links to get you started:  
[https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all](https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all)  
[https://processing.org/reference/libraries/serial/index.html](https://processing.org/reference/libraries/serial/index.html) (some of the examples need an update)  
[https://www.oreilly.com/library/view/arduino-cookbook-2nd/9781449321185/ch04.html](https://www.oreilly.com/library/view/arduino-cookbook-2nd/9781449321185/ch04.html)  
[https://github.com/processing/processing/tree/master/java/libraries/serial](https://github.com/processing/processing/tree/master/java/libraries/serial)

There are some examples that come with Processing and Arduino.

There is lots of discussion on this topic out there and in this forum also.

I have written all of my own serial communication routines building on what I have gleaned from examples and my own experience.

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 20, 2020, 8:19pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/3 "2020-05-20T20:19:56Z")

</div>

[https://processing.org/tutorials/electronics/](https://processing.org/tutorials/electronics/)

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [May 21, 2020, 4:56am UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/4 "2020-05-21T04:56:40Z")

</div>

glv

Thank you for the links.  
The serial part I understand. The examples are pretty clear.  
What I am looking for is how to create a user facing form/dialog in Processing to let the user type in numbers or select from a list. If I have the data from the user, I know how to get the data to/from the Arduino.  
So, the front end options/examples are what I need.  
E.G.,

- How to present text?
- how to capture text from the user?
- how does the user select from a list?  
Thomas Stephens DeSoto, TX

---

<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 21, 2020, 10:47am UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/5 "2020-05-21T10:47:44Z")

</div>

Hello,

I gleaned through the available resources and there may be something for you in there.

> **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/)
> - The Processing PDE (IDE) has lots to offer!  
> An exploration of the tabs will reveal what is available; libraries, tools and local 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 source code can give insight if you are adventurous:  
> [GitHub - processing/processing: Source code for the Processing Core and Development Environment (PDE)](https://github.com/processing/processing)  
> Many of the Processing functions are here:  
> [processing/core/src/processing/core/PApplet.java at master · processing/processing · GitHub](https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java)
> - 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.
> - And the Internet. `:)`

`:)`

Libraries:

> **[Libraries](https://processing.org/reference/libraries/)**
>
> Extend Processing beyond graphics and images into audio, video, and communication with other devices.

The libraries and tools in the Processing IDE:

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

`:)`

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [May 21, 2020, 12:31pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/6 "2020-05-21T12:31:25Z")

</div>

Thank you.  
I will give interfascia a try.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [May 27, 2020, 5:44pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/7 "2020-05-27T17:44:53Z")

</div>

@McLae5 – did interfascia end up working out for you?

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [May 27, 2020, 6:51pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/8 "2020-05-27T18:51:29Z")

</div>

no time to work with it yet.  
Still working on the program flow. Not the same as Arduino sketches.

Thomas Stephens DeSoto, TX

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [June 10, 2020, 4:04pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/9 "2020-06-10T16:04:23Z")

</div>

Interfascia looks like oit will do what I want, as soon as I learn more about Java. (Old C/C++ programmer)

Looking at the radio button example, I see how radio buttons are displayed, but how do I determine which has been selected? As in in finding which button was last pushed?  
I tried to set a text label with the selected button id/reference/index and could not figure out the syntax for converting an index into a parameter the label would take.  
If strings are static, how to I change the text in a string?  
This is likely simple JAVA, but new to me.

Documentation is not what I am use to.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [June 10, 2020, 5:10pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/10 "2020-06-10T17:10:08Z")

</div>

> [@McLae5](#):
>
> If strings are static, how to I change the text in a string?

```auto
String s = "foo";
s = "bar";

```

The String itself is a static object, but the variable can be reassigned to a new String.

Or, methods on the String don’t change the String, they return a new String – which you assign to the reference.

```auto
s = s.replace('r', 'z'); // bar -> baz

```

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [June 10, 2020, 6:46pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/11 "2020-06-10T18:46:53Z")

</div>

So the old string is destroyed automatically? (Java vs C memory management)

Any examples available for changing a text or label object based on radio button selection?  
As in, select this button, text says “First”, select second bubtton text says “Second”, back to first button, text says “First”.  
Looking for how to capture user action for further processing.

Thomas Stephens DeSoto, TX

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [June 10, 2020, 7:14pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/12 "2020-06-10T19:14:01Z")

</div>

> [@McLae5](#):
>
> So the old string is destroyed automatically?

Yes, it is eventually garbage-collected when no references point to it. If something still points to it, no, e.g.

```auto
String s = "bar";
String s2 = s;
s = s.replace("r", "z");

```

Now s = “baz”, while s2 = “bar” (the original String object, which still has a reference pointing to it, and won’t be garbage-collected).

---

<div class="post-metadata">

### Author: ![McLae5](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@McLae5](https://discourse.processing.org/u/McLae5)
#### Post date: [June 10, 2020, 10:16pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/13 "2020-06-10T22:16:52Z")

</div>

So does this work?  
String s = “Foo”’.  
s = “Bar”;  
print(s);  
Should show “Bar”, right?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [June 10, 2020, 10:43pm UTC](https://discourse.processing.org/t/how-do-i-use-processing-to-read-and-write-data-to-an-arduino/21113/14 "2020-06-10T22:43:09Z")

</div>

Yes – just paste it into PDE and try it!

```auto
String s = "Foo";
s = "Bar";
print(s);

```

> Bar
