Converting string to int
in
Programming Questions
•
1 year ago
Hey everyone, Iv never posted here before, I normally find what I need on here quite easily but I am now stuck.
I have search the forum for this issue and tried everything that has already been suggested but its still not working.
the program is designed to take a temperature reading from an Arduino Uno and use it as an int to be displayed on screen.
here are all the variables I'm using
int DT = 40; // Desired temp
int AT = 0; // Actual temp
int lf = 10; // line feed end signal sent by arduino
Serial myPort; // The serial port
String in = null ; //received string
this is the code I'm using to read the serial input and then convert the string
while (myPort.available() > 0)
{
in = myPort.readStringUntil(lf);
if (in == null)
{
}
else if (in != null )
{
AT = int(in);
print(in); //test
print (" / "); // test
println (AT); //test
}
}
any help or suggestions would be welcomed.
Thanks
Dedz
1