Create this program to make the robot drive in a square.
Near the bottom of the list, find "Make a Variable."
Click on Make a Variable, and name it "length"
Click on Make a Variable and make a second variable and name it "sides"
Modify the program to make a variables to replace the numeric values. Then test it on the robot, it should do the same thing as it did in the example above.
Using variables with a math operator,
The formula to calculate the outside angle of any regular polygon is.
360 degrees / number of sides = outside angle.
for a square the equation is 360/4 = 90.
On a square the inside angle and the outside angle are both 90 degrees.
Make this change on the program and test it. It should do the same as the first 2 programs.
By changing the variable for sides,
1) Change the variable sides to make the robot drive in a triangle and test it.
2) Change the variable sides to make the robot drive in a regular hexagon and test it.
NOTE: 360/sides = outside angle!
The formula works for any regular polygon, so the only thing you need to change is the code is the variable for sides.
Make the robot drive in a hexagonal spiral pattern, by changing the length variable.