# \[SOLVED\] serial port write with no delay between bytes when sending hex values

**URL:** https://discourse.processing.org/t/solved-serial-port-write-with-no-delay-between-bytes-when-sending-hex-values/3712
**Category:** Electronics (Arduino, etc.)
**Created:** [September 21, 2018, 2:32pm UTC](https://discourse.processing.org/t/solved-serial-port-write-with-no-delay-between-bytes-when-sending-hex-values/3712 "2018-09-21T14:32:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matt6ft9](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@matt6ft9](https://discourse.processing.org/u/matt6ft9)
#### Post date: [September 21, 2018, 2:32pm UTC](https://discourse.processing.org/t/solved-serial-port-write-with-no-delay-between-bytes-when-sending-hex-values/3712/1 "2018-09-21T14:32:31Z")

</div>

I’m trying to send hex data out of the FTDI serial port IC at 19200, 8N1. (windows 7, processing 3.3.6)

When I use this code:

```auto
public void button2(){
  int i;
  int collect[] = {0x55,0x02,0x50,0xFE,0x20,0x20,0x20,0x20,0x30,0x03};

  intTxCnt+=1;
  print("Sent (dec) " + intTxCnt + " : "); 

  for(i = 0 ; i < collect.length ; i++) 
  {
      myPort.write(collect[i]);
      print(collect[i]);
      print(" ");
  }
  println(" ");
}

```

There is a roughly 0.6mS to 1.2mS delay between bytes. (I’m using a logic analyzer to see this) (it is easy to see why there is a delay, only one byte is loaded in at a time and windows 7 makes the delay variable)

When a string is written to the serial port, there is no variable delay between bytes:

```auto
  myPort.write("hello");

```

But, what I would like to do is write the hex (binary or non-ASCII) values in the “collect” array without the variable delay between the bytes. Any thoughts on how to do this?

Matt Meerian

---

<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: [September 21, 2018, 2:40pm UTC](https://discourse.processing.org/t/solved-serial-port-write-with-no-delay-between-bytes-when-sending-hex-values/3712/2 "2018-09-21T14:40:42Z")

</div>

Change _collect_’s datatype to `byte[]`, and pass it as Serial::**write()**'s argument.

> **[write() / Libraries](https://processing.org/reference/libraries/serial/Serial_write_.html)**
>
> Writes bytes, chars, ints, bytes\[\], Strings to the serial port

> [@Udp problem sending byte (-127)](https://discourse.processing.org/t/udp-problem-sending-byte-127/3545/2):
>
> Can’t you simply send() the byte[] array instead of a String? thinking udp.send(mist, ip, port); [UBAA.net/shared/processing/udp/udp\_method\_send.htm](http://UBAA.net/shared/processing/udp/udp_method_send.htm)

---

<div class="post-metadata">

### Author: ![matt6ft9](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@matt6ft9](https://discourse.processing.org/u/matt6ft9)
#### Post date: [September 21, 2018, 3:27pm UTC](https://discourse.processing.org/t/solved-serial-port-write-with-no-delay-between-bytes-when-sending-hex-values/3712/3 "2018-09-21T15:27:58Z")

</div>

That did the trick, it works wonderfully.  
GoToLoop, thanks for the help.  
matt
