Manipulating a Variable

Look at the following code:

Notice on line 12 we have a variable “degreesToTurn=90”. We call on that variable on line 14 and line 16. Do you notice anything different about the variable on line 16? We added some math! We stated we want the “degreesToTurn” variable to be multiplied by 3. That should mean that Edison should turn 270 degrees. 

Practice

  • Try writing and running this code. Does Edison listen to the math and turn 270 degrees?
  • Try manipulating your variable with other math expressions such as – + / * (subtract, add, divide, multiply). 

Note

The maximum value for degrees to turn is 360. If you put a value higher than 360 you won’t get an error message but instead Edison will “wrap” the value to do a shorter turn. For example: An input of 380 will cause Edison to turn 20 degrees. In EdPyapp you can search the documentation section for Ed.Drive() to learn more about the parameters.