# Using two different readStringUntil "characters"

**URL:** https://discourse.processing.org/t/using-two-different-readstringuntil-characters/10769
**Category:** Electronics (Arduino, etc.)
**Tags:** homework
**Created:** [April 29, 2019, 11:10pm UTC](https://discourse.processing.org/t/using-two-different-readstringuntil-characters/10769 "2019-04-29T23:10:54Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [April 30, 2019, 11:29am UTC](https://discourse.processing.org/t/using-two-different-readstringuntil-characters/10769/6 "2019-04-30T11:29:12Z")

</div>

The solution I gave on that link expects the Arduino C code to send the multi-data as if they were a row of **tab-separated values** ( **TSV** ): 🧐

> **[Tab-separated values](https://en.wikipedia.org/wiki/Tab-separated_values)**
>
> A tab-separated values (TSV) file is a simple text format for storing data in a tabular structure, e.g., database table or spreadsheet data, and a way of exchanging information between databases. Each record in the table is one line of the text file. Each field value of a record is separated from the next by a tab character. The TSV format is thus a type of the more general delimiter-separated values format.
> TSV is a simple file format that is widely supported, so it is often used in data exchan...

That is, each value is followed by a `\t` character; except last 1, which is followed by an `\n` instead: 🤓

```auto
Serial.print(temperature);
Serial.write('\t');
Serial.print(masse);
Serial.write('\t');
Serial.print(humidite);
Serial.write('\t');
Serial.print(comptage);
Serial.write('\t');
Serial.println(son); // implies '\n'

```

At the Processing Java side, each data row is received whole via Serial::**readString()**, then split as an array via PApplet::**splitTokens()**, and then converted to `float[]` via PApplet::**float()**: ☕

1. [Processing.org/reference/libraries/serial/Serial\_readString\_.html](http://Processing.org/reference/libraries/serial/Serial_readString_.html)
2. [Processing.org/reference/splitTokens\_.html](http://Processing.org/reference/splitTokens_.html)
3. [Processing.org/reference/floatconvert\_.html](http://Processing.org/reference/floatconvert_.html)

```auto
float[] vals = {};

void serialEvent(final Serial s) {
  vals = float(splitTokens(s.readString()));
  redraw = true;
}

```

Full code from the original post: 🕶

```auto
/**
 * Efficient Serial Multi-Value Reading (v1.1.2)
 * GoToLoop (2015-Feb-18)
 *
 * Forum.Processing.org/two/discussion/14988/
 * drawing-of-graphs-from-i2c-imu#Item_3
 *
 * Forum.Processing.org/two/discussion/16618/
 * processing-with-arduino-void-serialevent#Item_1
 *
 * Discourse.processing.org/t/
 * using-two-different-readstringuntil-characters/10769/6
 */

import processing.serial.Serial;

static final int PORT_INDEX = 0, BAUDS = 9600;

int[] vals = {};
//float[] vals = {};

void setup() {
  noLoop();
  final String[] ports = Serial.list();
  printArray(ports);
  new Serial(this, ports[PORT_INDEX], BAUDS).bufferUntil(ENTER);
}

void draw() {
  println(vals);
}

void serialEvent(final Serial s) {
  vals = int(splitTokens(s.readString()));
  //vals = float(splitTokens(s.readString()));
  redraw = true;
}

```

---

_[View the full topic](https://discourse.processing.org/t/using-two-different-readstringuntil-characters/10769)._
