If / Else | 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
L'instruction if/else (si/sinon en français) permet un meilleur contrôle du déroulement du programme que la simple instruction if, en permettant de grouper plusieurs tests ensemble. Par exemple, une entrée analogique peut-être testée et une action réalisée si l'entrée est inférieure à 500, et une autre action réalisée si l'entrée est supérieure ou égale à 500. Le code ressemblera à cela :
if (brocheCinqEntree < 500) { // action A } else { // action B }else peut contenir un autre test if, et donc des tests multiples, mutuellement exclusifs peuvent être réalisés en même temps.
Chaque test sera réalisé après le suivant jusqu'à ce qu'un test VRAI soit rencontré. Quand une condition vraie est rencontrée, les instructions associées sont réalisées, puis le programme continue son exécution à la ligne suivant l'ensemble de la construction if/else. Si aucun test n'est VRAI, le bloc d'instructions par défaut else est exécuté, si il est présent, déterminant ainsi le comportement par défaut.
Noter qu'un bloc else if peut être utilisé avec ou sans bloc de conclusion else et vice versa. Un nombre illimité de branches else if est autorisé.
if (brocheCinqEntree < 500) { // faire l'action A } else if (brocheCinqEntree >= 1000) { // faire l'action B } else { // faire l'action C }Une autre façon de réaliser un branchement de tests multiples mutuellement exclusifs est l'instruction switch case.
Exemple
The below code deternine numbers are odd or even
int i = 0; void setup() { Serial.begin(9600); } void loop() { if ((i % 2) == 0) { Serial.print("Inside the IF statement: i = "); Serial.print(i); Serial.println(", even number"); } else { Serial.print("Inside the IF statement: i = "); Serial.print(i); Serial.println(", odd number"); } i++; // increase i by 1 delay(500); }The result on Serial Monitor:
COM6 Send Inside the IF statement: i = 0, even number Inside the IF statement: i = 1, odd number Inside the IF statement: i = 2, even number Inside the IF statement: i = 3, odd number Inside the IF statement: i = 4, even number Inside the IF statement: i = 5, odd number Inside the IF statement: i = 6, even number Inside the IF statement: i = 7, odd number Autoscroll Show timestamp Clear output 9600 baud Newline※ 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 Code If Else Statement
-
Else - Arduino Reference
-
If Statement (Conditional Statement) | Arduino
-
If Statement (Conditional Statement) - Arduino Documentation
-
Arduino If-else Statement - Linux Hint
-
Arduino IDE: Conditional(if-else-if) Statements - STEMpedia
-
Arduino If-else And Else-if - JavaTpoint
-
Arduino - If…else If …else Statement
-
How To Use Conditional Statements In Arduino Programming
-
Tutorial 11: If Statement (and Else-if), Comparison Operators And ...
-
Arduino: If/Else Statements - YouTube
-
Arduino Code: Conditional Statements - YouTube
-
Making Decisions With If-else In Arduino Programming
-
2.7 Understanding If / Else And While Statement In Arduino
-
If And If Else Statement In Arduino Programming