Professional Documents
Culture Documents
ABE-13 Arduino-Lab Chapter-III 230314 111636
ABE-13 Arduino-Lab Chapter-III 230314 111636
Arduino_Conditional Statements
ABE 13
What you are going to study in
this Chapter?
1. Familiarize themselves with different logical statements.
2. Construct the circuit using the different logical combinations.
3. Create the program or codes using the different logical statements.
4. Build a circuit showing the output characteristics of each logical statement.
What you are going to study in
this Chapter?
1. IF statements
2. Else statements
3. While statements
4. Combinations using the Logical Propositions (And, Or and Not)
5. For Statements .
Conditional Statements
• Conditional statements function similarly to tests in that they
determine whether or not a condition is true. If the condition
is met, the code contained inside the conditional expression is
run. The code is not performed if the condition is false. The if
statement is the most widely used conditional expression.
• This statements allows the users to control the flow of a
program based on certain conditions that you can define in
the code.
Conditional Statements
• “IF” statement
-Typically, if statements are put inside the loop() section, where
they are evaluated once for each iteration. This is the code for
an if statement.
if (condition) {
body;
}
-The code included in the body is only run if the condition is
met. The usual form of the conditional statement tests whether
or not the variable in question is less than, larger than, or equal
to a certain digit. No matter what condition is employed, it must
provide a true or false result.
Conditional Statements
• “IF” statement
Conditional Statements
• “IF” statement
list of all relational operators that can be used in conditional
statements:
if (input == HIGH) {
digitalWrite(ledPin, HIGH)
if(temp < 20) {
Serial.print("Low Temperature!");
}
if(temp > 20){
Serial.print("High Temperature!");
}
}