Serial.setTimeout()
Descripción
Serial.setTimeout() establece los milisegundos de espera máximos para datos serie utilizando :
Su valor predeterminado es 1000 milisegundos.
Serial.setTimeout() hereda de la clase Stream.
Sintaxis
Serial.setTimeout(time)
Parámetros
- time: duración del tiempo de espera en milisegundos (long).
Retornos
- Ninguno.
Ejemplo
- Compile and upload the below code to Arduino
- Type "Arduino" on Serial Monitor and click Send button:
- The result on Serial Monitor:
- Modify the code to change timeout from 100ms to 1ms
- Compile and upload the below code to Arduino
- Type "Arduino" on Serial Monitor and click Send button:
- The result on Serial Monitor:
When timeout is small, a single string is read multiple time.
※ Nota:
Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:
- An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)
Ver También
- Lenguaje: Arduino - Serial
- Lenguaje: Serial.available()
- Lenguaje: Serial.availableForWrite()
- Lenguaje: Serial.begin()
- Lenguaje: Serial.end()
- Lenguaje: Serial.find()
- Lenguaje: Serial.findUntil()
- Lenguaje: Serial.flush()
- Lenguaje: if(Serial)
- Lenguaje: Serial.parseFloat()
- Lenguaje: Serial.parseInt()
- Lenguaje: Serial.peek()
- Lenguaje: Serial.print()
- Lenguaje: Serial.println()
- Lenguaje: Serial.read()
- Lenguaje: Serial.readBytes()
- Lenguaje: Serial.readBytesUntil()
- Lenguaje: Serial.readString()
- Lenguaje: Serial.readStringUntil()
- Lenguaje: serialEvent()
- Lenguaje: Serial.write()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |