# Unable to receive serial data from Arduino

**URL:** <https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [September 21, 2019, 10:43pm UTC](https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100 "2019-09-21T22:43:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 22, 2019, 2:09am UTC](https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100/3 "2019-09-22T02:09:43Z")

</div>

i would avoid byte things at all,  
stick with readable ASCII you can follow in arduino monitor ( terminal )  
and easy debug in processing.  
ARDUINO

```auto

// https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100
// kll tested also with a arduino leonardo

//Arduino program::
//To send on the serial port a value defined by the
//cursor of a potentiometer

#define POT 0 //assigns input 0 to the potentiometer
int val = 0; //val is the input variable

void setup() {
  Serial.begin(9600);//open the serial port and
  // set the speed at 9600 bit/sec
}

void loop() {
  val = analogRead(POT);//read the voltage on pin A0 and name it val
// Serial.print(val);//transmit val to the serial port
  Serial.println(val);//transmit val to the serial port
// delay (10); //wait 10mS ( 100 lines per sec ?)
  delay (100); //wait ( 10 lines per sec better start slow )
}

```

PROCESSING 3.5.3

```auto
import processing.serial.*;
Serial myPort;
String data, val="NaN";
int var;

void setup_serial() { // USB arduino..
  printArray(Serial.list());
  String portName = Serial.list()[1]; // adjust you arduino USB port
  myPort = new Serial(this, portName, 9600);
  myPort.clear();
  myPort.bufferUntil('\n');
  println("try connect to "+portName);
}

void serialEvent(Serial p) { // handle serial data
  data = trim(p.readStringUntil('\n'));
  if (data != null) {
    val = data;
    var = int(val);
    println("val "+val+" var "+var); // print every GOOD line and if it is understood 
  }
}

void setup() {
  size(640, 360);
  setup_serial();
}

void draw(){}

```

---

_[View the full topic](https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100)._
