Serial.setTimeout()
Description
Cette fonction fixe le délai maximum en millisecondes à attendre pour la lecture de flux de données. La valeur par défaut est 1000 millisecondes (=1 seconde).
En pratique, ce délai est utilisé par les fonctions de la classe Serial suivantes:
Syntaxe
Paramètres
- Serial: tout objet d'une classe utilisant la classe Serial
- time: délai maximum en millisecondes à attendre pour la lecture de flux de données (long)
Valeurs Renvoyées
- Aucune
Exemple
- 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 above 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.
※ Remarque:
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)
Voir Également
- Langage: Arduino - Serial
- Langage: Serial.available()
- Langage: Serial.begin()
- Langage: Serial.find()
- Langage: Serial.findUntil()
- Langage: Serial.flush()
- Langage: Serial.parseFloat()
- Langage: Serial.parseInt()
- Langage: Serial.peek()
- Langage: Serial.print()
- Langage: Serial.println()
- Langage: Serial.read()
- Langage: Serial.readBytes()
- Langage: Serial.readBytesUntil()
- Langage: Serial.write()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |