Change what the program does depending on the value of a state variable.
This tutorial is part of the Nairda learning path. You can build it step by step inside the app, which checks every block you place before letting you move on.
The steps
- We add a While loop, which repeats forever.
- We create a number variable called state.
- We create another number variable called output.
- Inside the loop we put an If with a comparison.
- That If asks whether state is 1.
- If state is 1, output becomes 20.
- Above it we put a second If, with its own comparison.
- That other If asks whether state is 0.
- If state is 0, output becomes 10.
- On the dashboard we put a slider to move the state.
- And a label with output, which changes with the state.
When you finish, the app takes you straight to the next tutorial in the path.