Hi people !
I'm really intrigate with this problem.
I'm using powershell script for comunication between pc and arduino but i think that i'm having encoding problem or something like that, cuz, for exemple, when I pass a number from shell scritp, arduino receive any other thing but not this number.
Can you helpe me ?
What you're seeing on the LCD is the ASCII codes for the characters you sent to the Arduino. You can fix this by using lcd.write() instead of lcd.print(). print() uses the data type of the parameter passed to it to determine how it should be displayed. Since the data type of var is int, print() thinks it should display the numerical value. If the type of var was char, print() would instead display the character associated with the ASCII code for the value of var. write() doesn't do any of that fancy stuff. It assumes that the parameter is an ASCII code and always displays the character representation of that code.
Thaks for your help. I understood what you said. That was really interesting cuz i didn't know about that.
But, as you can see, at the shell script, i'm passing number 1(int). Now its showing on lcd -1 following of some squares. I didn't change the code.
You aren't waiting to update the LCD screen until you have data in the serial RX buffer. Because of this, when you call var=Serial.read(); you have a high likelihood of getting a "no data in the buffer" error code '-1'. Even if you do get the char you sent with the script, it will be overwritten by a '-1' when you call var=Serial.read(); during the next iteration of loop()