# Error on my Processing GUI code for Arduino , I need some help

**URL:** <https://discourse.processing.org/t/error-on-my-processing-gui-code-for-arduino-i-need-some-help/33341>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [November 5, 2021, 5:08pm UTC](https://discourse.processing.org/t/error-on-my-processing-gui-code-for-arduino-i-need-some-help/33341 "2021-11-05T17:08:22Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [November 7, 2021, 10:37am UTC](https://discourse.processing.org/t/error-on-my-processing-gui-code-for-arduino-i-need-some-help/33341/6 "2021-11-07T10:37:49Z")

</div>

Hi @fdinumario, Looking at your original code I want to suggest something that will make shrink the code and make it easier to adjust the comms scheme.

Where you have items like this repeated

```auto
  Serial.print("rainin=");
  Serial.print(rainin, 2);
  Serial.println();

```

Simplify by writing a new function:

```auto
void prntValue(char label[], float value, int nofDec)
{
   Serial.print(label);
   Serial.print(value, nofDec);
   Serial.println();
}

```

Now your list of sending becomes:

```auto
  prntValue("rainin=" , rainin , 2);
  prntValue("dailyrainin=", dailyrainin, 2);

```

Your original code is meant to print labels and values on the serial monitor, but if you want to convert to @glv suggestion you have to alter every printing line. With the function you only have to make the changes once. You could use a function in your Processing to replace the pairs of lines

```auto
text("Rainfall:",50,350);
text(rainin,250,350);

```

This pays off here as well, because I think you need textAlign(LEFT) for the label and RIGHT for the value.

Serial: You need a simple definition for what the message is, and in your original the labels make things complicated. Suggest you try glv’s example and my [example](https://discourse.processing.org/t/processing-and-arduino-serial-example/31650). It will help you to see serial comms simply working.

Please try all that and describe the remaining troubles.

---

_[View the full topic](https://discourse.processing.org/t/error-on-my-processing-gui-code-for-arduino-i-need-some-help/33341)._
