Boucle While | Référence Du Langage Arduino En Français
Maybe your like
- TUTORIALS
- HARDWARE & TOOLS
- REFERENCES
- FAQs
- ABOUT US
- English |
- Deutsch |
- Português |
- 한국어 |
- Français |
- Español
Sketch
- loop()
- setup()
Control Structure
- break
- continue
- Boucle do - while
- if / else
- Boucle for
- goto
- if (condition)
- return
- switch / case
- Boucle while
Further Syntax
- // et /* */ Commentaires
- {} Accolades
- #define
- #include
- ; point virgule
Data Types
- Tableaux de variables
- boolean
- byte
- char
- double
- float
- int
- long
- Les chaînes de caractères
- String()
- unsigned int
- unsigned long
- void
- word
Constants
- Les constantes Arduino prédéfinies: INPUT, INPUT_PULLUP, OUTPUT, HIGH, LOW, LED_BUILTIN, true, false.
- Floating Point Constants
- Les expressions numériques entières
Variable Scope & Qualifiers
- const
- La portée des variables
- static
- volatile
Digital IO
- digitalRead()
- digitalWrite()
- pinMode()
Analog IO
- analogRead()
- analogReference(type)
- analogWrite()
Advanced IO
- noTone()
- pulseIn()
- shiftOut()
- tone()
Serial
- Librairie Serial pour la communication série
- Serial.available()
- Serial.begin()
- Serial.find()
- Serial.findUntil()
- Serial.flush()
- Serial.parseFloat()
- Serial.parseInt()
- Serial.peek()
- Serial.print()
- Serial.println()
- Serial.read()
- Serial.readBytes()
- Serial.readBytesUntil()
- Serial.setTimeout()
- Serial.write()
Stream
- Librairie Stream
- Stream.available()
- Stream.find()
- Stream.findUntil()
- Stream.flush()
- Stream.parseFloat()
- Stream.parseInt()
- Stream.peek()
- Stream.read()
- Stream.readBytes()
- Stream.readBytesUntil()
- Stream.setTimeout()
String Functions
- String.charAt()
- String.compareTo()
- String.concat()
- String.endsWith()
- String.equals()
- String.equalsIgnoreCase()
- String.getBytes()
- String.indexOf()
- String.lastIndexOf()
- String.length()
- String.replace()
- String.setCharAt()
- String.startsWith()
- String.substring()
- String.toCharArray()
- String.toLowerCase()
- String.toUpperCase()
- String.trim()
String Operators
- String opérateur +=
- String.opérateur ==
- String opérateur +
- String [] (accès à un élément)
Time
- delay()
- delayMicroseconds()
- micros()
- millis()
Math
- abs()
- constrain()
- map()
- max()
- min()
- pow()
- sq()
- sqrt()
Bits and Bytes
- bit()
- bitClear()
- bitRead()
- bitSet()
- bitWrite()
- highByte()
- lowByte()
Arithmetic Operators
- + Addition
- = opérateur d'assignement
- / Division
- * Multiplication
- % (modulo)
- - Soustraction
Bitwise Operators
- << (Décalage des bits vers la gauche)
- >> (Décalage des bits vers la droite)
- & (Opérateur "bit à bit" ET)
- ~ (Opérateur "bit à bit" NON)
- | (Opérateur bit à bit OU)
- ^ (Opérateur "bit à bit" OU EXCLUSIF)
Boolean Operators
- && (ET logique)
- ! (NON logique)
- || ( OU logique)
Compound Operators
- += (addition composée)
- &= (ET bit à bit composé)
- |= (OU bit à bit composé)
- /= (division composée)
- *= (multiplication composée)
- -= (soustraction composée)
- -- (décrément)
- ++ (incrément)
Conversion
- byte()
- char()
- float()
- int()
- long()
Random Numbers
- random()
- randomSeed()
Trigonometry
- cos()
- sin()
- tan()
External Interrupts
- attachInterrupt (interruption, fonction, mode)
- detachInterrupt(interruption)
Interrupts
- interrupts()
- noInterrupts()
Utilities
- PROGMEM
- sizeof
Pointer Access Operators
- Les pointeurs : & (référence) et * (déréférence)
Description
Les boucles while ("tant que" en anglais) bouclent sans fin, et indéfiniment, jusqu'à ce que la condition ou l'expression entre les parenthèses ( ) devienne fausse. Quelque chose doit modifier la variable testée, sinon la boucle while ne se terminera jamais. Cela peut être dans votre code, soit une variable incrémentée, ou également une condition externe, soit le test d'un capteur.
Syntaxe
while(expression){ // tant que l'expression est vraie // instructions à effectuer }Paramètres
- expression: Une instruction (booléenne) C qui renvoie un résultat VRAI ou FAUX.
Exemple
void setup() { Serial.begin(9600); Serial.println("====== TEST START ======"); int i = 0; while (i < 5) { // tant que la variable est inférieur à 5 // fait quelque chose 5 fois de suite... Serial.print("Inside the WHILE loop: i = "); Serial.println(i); i++; // incrémente la variable } Serial.println("====== TEST END ========"); } void loop() { }In the example above, the code in the loop will run, over and over again, as long as a variable (i) is less than 5.
The result on Serial Monitor:
COM6 Send ====== TEST START ====== Inside the WHILE loop: i = 0 Inside the WHILE loop: i = 1 Inside the WHILE loop: i = 2 Inside the WHILE loop: i = 3 Inside the WHILE loop: i = 4 ====== TEST END ======== Autoscroll Show timestamp Clear output 9600 baud Newline※ Remarque:
- When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop.
- The following while loop loops forever:
- There are three ways to escape the while loop:
- The condition of the while loop becomes false.
- The execution of the code reaches a break statement inside the loop.
- The execution of the code reaches a goto statement inside the loop, which jumps to a label located outside of the loop.
※ ARDUINO BUY RECOMMENDATION
| Arduino UNO R3 |
| Arduino Starter Kit |
※ OUR MESSAGES
- We are AVAILABLE for HIRE. See how to hire us to build your project
Tag » Arduino If Else While
-
If/while Loop - Programming Questions - Arduino Forum
-
While - Arduino Reference
-
"if" Inside "while" - Programming Questions - Arduino Forum
-
If/while Statement - Programming Questions - Arduino Forum
-
While...else Statement For Arduino - Stack Overflow
-
2.7 Understanding If / Else And While Statement In Arduino
-
Arduino While Loop, If/if Else Statement - YouTube
-
Explain The While Loop In Arduino With The Help Of Examples
-
If, For, While, Map, And Switch Cases - Arduino - Instructables
-
Nesting Loops - If Statement In A While Loop - Arduino Stack Exchange
-
Arduino While Loop - JavaTpoint
-
Arduino IDE: Conditional(if-else-if) Statements - STEMpedia
-
Arduino While And Do-while Loops | Programming Course Part 8
-
Arduino While Loop: How You Can Use This Loop In Two Ways