Sensor Value: Undefined
I was confused about some problems that happened during my running program. I understand that I should have P5 closed every time I make changes in Arduino. However, the error message would still come out sometimes. Although I did succeed for few times, I still have no idea what the error message means and why it happens.
In the failed version, the serial console can work as I turned the potentiometer; however, the screen still showed undefined.
I don't understand the message.
The succeeded version happened when I turned off my P5, re-loaded Arduino, re-opened P5, re-scanned the port. After a whole set of restarts, it worked.
Why the number always shows between 48 - 57:
A: The number here is not the number value, instead, it is the character value; "1" → 48
A:
```jsx
//serial.write; serial.read; serial.print
function serialEvent() {
var input = serial.readLine();
consle.log(input);
if (input) {
receivedData = input;
}
}
```
Answers to my question
A: The same problem as P5 can not read from Arduino; The solution should be when use serial.read in Arduino, use serial.write in P5.
B: Can't find the client (P5 serial control can't connect with p5.js); the solution is might to just restart and re-connect the whole set.
A:
//DO NOT DO ANYTHING UNTIL I ENTER A CHARACTER
if (serial.available() > 0 )
int inChar = serial.read()
serial.write (inChar);
if (inChar = 32) {
digitalWrite(LED.BUILTIN , HIGH)
}
else