Decimal number reading

Hi,
Maybe a totally stupid question, but im getting confused. How does an ARDUINO read for example a
text that in hyperterminal shows like “%123/7”
Its a mix of decimal numbers and a “%” and a “/”.
does the arduino read it as it is, or convert to something else??

If it is sent as ASCII it will read what is sent.

load this and send your message. Make sure the serial monitor baud rate matches the code.

void setup()
{
    Serial.begin(115200);    
}

void loop()
{
  if(Serial.available())
  {
   Serial.print(char(Serial.read())); // char() converts the ASCII character code to print the character
  }
}

If you use Serial.parseInt() or Serial.parseFloat() the Arduino will throw away characters until it finds one that could be part of a number. Then it will include characters that can be part of a number. Then, when it finds a character that can't be part of a number or the timeout period expires (default: 1 second) it returns the number. If the timeout happens before the number starts, it returns zero.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.