TurtleStitch

10. How To Create a Variable on TurtleStitch

Variables in TurtleStitch

When creating different patterns on TurtleStitch it is good to use variables to help shorten your code.

Here is how you can create a variable and how it is used to create a pattern.

  1. To start off, you need to go the variable section and click on make a variable. When you do this, a box will come up to name your variable. The variable should have a valid name so when you come back and look at your block of code, the variable name makes sense to you.

  2. In this example, I will be calling the variable sideLength. Then click OK.

  3. If you stay in the variable section, you will see two buttons, the set [] to [] and change [] by [].

  4. You can set sideLength to any number you would like. Try different numbers and see what your pattern looks like. If you want to make some sort of spiral and you want it to get bigger each loop, you can change sideLength by 10 or any number that you would like.

  5. You can also insert this variable into different motion blocks.

    This is the variable section:

    Variables Section

  6. Now, I will show you how to create a block of code using variables.

  7. You are going to need your reset and repeat button from the control section. Set repeat to 12.

  8. You will also need a type of stitch, in this case, I will be using a running stitch by 10. Insert this stitch button between reset and repeat.

  9. Below your running stitch button, you will need to inset a set [sideLength] to [30]. sideLength is my variable I created, and I am setting that number to 30.

  10. Get a move steps button and where you enter a number, you will insert you sideLength variable into there. Put that button into your repeat loop.

  11. After that you will need turn degrees set that to 120.

  12. The last step is to grab the change [] by [] button from the variable section and put in sideLength and a number of your choice. I will be putting in 20.

  13. Now click your block of code and you should get the following pattern:

Final Block Of Code And Pattern

Created by: Hope Boyle