Programming a Move Procedure
Now we want to turn your algorithm into a reusable procedure - there are 5 columns on this grid and one measure of our success is for the program to work for ANY size grid
Find the Functions Block -

Click create a function and then title it moveDown - do not be distracted by the other options on the screen. And then hit done

Inside the moveDown Function
//this is my fully realized moveDown function
Repeat 4
move boat 1
pause 1000ms
boat turn left 90
boat move by 1
pause 1000 ms
boat turn left by 90
Now to test it by calling the function. When you return to the Functions tab you should see 1 block - the call moveDown
TIP:When we use a function we are calling it
On Start
boat to 0,0
turn boat left 90
A Button Pushed
call moveDown
Test this code several times and make sure it is traversing each LED down the column. Do you need to adjust turns?
Last updated