Getting Started Guide
CLASS 4
38
Now, you need to change the value of “fanState” to “on” and “off” whenever the infrared sensor is pressed.
True
False
As a review, the variable you made needs to have a value of either “on” or “off”. To display the flow chart above,
conditional statement such as “if~ or” is necessary. If the condition of tester is already at “off”, you need to change
the value of variable “fanState” to “on.” If not, you need to change the variable value to “off.” If you do this, you will
be able to see the value saved in the variable “fanState” changing whenever the user presses the infrared sensor.
Take a look at the code shown below.
Now combine the codes you made previously. Don’t forget the infinite repeat block!
Coding a Drone
Is the tester
turned off?
set the tester
condition to “off’
Set the tester
condition to
“on”
Drone Coding Activity