Controlling the Big Wheel with Flowol
In this lesson you'll learn two important features of Flowol control, which are important features of any computer program
- Subroutines: A subroutine is a little program that runs inside a bigger one. We use subroutines when we want to repeat something often. Rather than put the repeated code in the main program, we create a subroutine and call it repeatedly from the main program
- Variables A variable is a 'memory space' that can hold a value. We can modify that value when the program runs, useful for keeping count of things that happen in our program.
Getting Started
Open the 'Big Wheel' mimic from the mimic menu in Flowol.
Take some time to understand the four different inputs.
|
Exercise 1 - Get some attention!
To attract the crowd, use the input 1 [button] to control the lighting effects on the wheel. This might be a simple on/off routine but flashing sequences are more exciting.
|
Use a Flowol Subroutine. To make a subroutine, drag an oval symbol (like the start and stop symbols) and click 'Sub'. Give it a name. Now create the blocks that tell the subroutine what to do. Finish with a 'Stop'
|
Exercise 2 - Make the wheel turn
Use the input 2 to control the simple Go/Stop movement of the wheel. [You could perhaps make the wheel speed up and slow down in stages by changing the motor power.
Exercise 3 - Add safety features
Exercise 4 - Stop the wheel automatically
Construct this counting program to increase the variable „y‟ each time a seat passes the steps i.e. each time the „virtual‟ input 4 goes off and on.
Since there are seven seats, each rotation of the wheel should increase the variable „y‟ by 7.
Now modify your program, by introducing a decision symbol, to stop the wheel automatically after it has rotated 3 times.
Since there are seven seats, each rotation of the wheel should increase the variable „y‟ by 7.
Now modify your program, by introducing a decision symbol, to stop the wheel automatically after it has rotated 3 times.
Creating variables in Flowol:
You can use variables to keep count. Drag a rectangular block onto the program area and choose 'let'. Select one of the variables to modify, for example variable 'a'. You can set the variable to a value or to some calculation. In the example on the right we set a to increase by one. You can see the results of your variable and watch it as it changes, by choosing 'View' and 'Variables' from the main menu.
|