Deciding how i am going to calibrate my GRS (STRESS) sensor to produce an increasing visual flashing lights in correlation to the reading from the stress sensor."if, which is used in conjunction with a
comparison operator, tests whether a certain condition has been
reached, such as an input being above a certain number. The format for
an if test is:if (someVariable > 50)
{
// do something here
}
The program tests to see if someVariable is
greater than 50. If it is, the program takes a particular action. Put
another way, if the statement in parentheses is true, the statements
inside the brackets are run. If not, the program skips over the code.
The brackets may be omitted after an if statement. If this is done, the next line (defined by the semicolon) becomes the only conditional statement.
if (x > 120) digitalWrite(LEDpin, HIGH); if (x > 120) digitalWrite(LEDpin, HIGH); if (x > 120){ digitalWrite(LEDpin, HIGH); } if (x > 120){ digitalWrite(LEDpin1, HIGH); digitalWrite(LEDpin2, HIGH); } // all are correct The statements being evaluated inside the parentheses require the use of one or more operators:
Comparison Operators:
x == y (x is equal to y)
x != y (x is not equal to y)
x < y (x is less than y)
x > y (x is greater than y)
x <= y (x is less than or equal to y)
x >= y (x is greater than or equal to y)
No comments:
Post a Comment