Professional Documents
Culture Documents
Session 7: If Statement
Daily Life Examples of
Conditional Statements
If Statement!
It’s a very commonly used and important
command for any condition we want!
} Example: if the
PushButton is
pressed, turn on the
LED!
In the conditions,
numbers can be used!
Random Example:
Be Careful!
Do not use single equal (=) sign alone!
The equal sign will assign x to a value,
which will make the condition always
TRUE!!
These comparison operations can be used as condition in the
If Statement
Let’s make an Example!
What if I want to have a
PushButton and a LED, in
condition that the LED won’t
turn On Unless the
PushButton is pressed
and it only turns Off
when it’s released?
If button is pressed If we get 5v from ButtonPin
turn on the LED put 5v on LEDpin
else else
turn off the LED put 0v on LEDpin