String to Integer for serial data
in
Programming Questions
•
2 years ago
Hi, i don't know what i am doing wrong. I have this code to read numbers that come as string from the serial port.
-
void serialEvent(Serial port) {
- String inBuffer = port.readStringUntil(00); //THis read the number "00" is the end of the number string
-
if (inBuffer != null) {y = int(inBuffer); //im trying to convert the string to int
println(y); //this print 0 - println(inBuffer); //this print the correct number
- output.println(y+"\n"); //this stores only 0's
}
The problem is that when convert "inBuffer" to int it becomes "0", the "inBuffer" string have the correct value of the number e.g "121" ,"922",etc. but when i try to convert it to an int in "y" it appear that the value is 0. Anyone can help me please?
1
