Data Sheet
26
DRAW A SHAPE USING JAVASCRIPT
9
A square has four equal sides, and four 90
degree corners. Because there are four corners
and four edges, it is worth writing control
functions for turning and driving to do this,
rather than writing the same code four times.
Next, make a function that takes the desired number of degrees to turn
and drives the servos to achieve that. To do this the function will turn on
the servos, wait a period, and then turn them off. The following function
turns Left through approximately the requested number of degrees.
STEP 1: In the JavaScript Blocks Editor, create the following variables.
WHAT THIS MEANS
These tell the micro:bit about how fast the
servos are moving, they allow easy tuning of
the Javascript code.
These are used to store some constants about the :MOVE mini.