PROJECTS: Using Servos with MakeCode
SERVOS AND MAKECODE
MakeCode is a free block-based programming
language created by Microsoft to help students
learn coding. It looks and feels very much like
MIT’s Scratch. The biggest difference is that your
program runs on an on-screen simulation as you
build it. You can program lights to flash when you
push a button, or music to play when the board
shakes, and watch the animated simulation to
see if you got everything right. You don’t need to
download MakeCode to your computer. Build
your program in your web browser, then
download it to the micro:bit board. There’s also
a MakeCode Offline App that works on computers
running Windows or MacOS.
To get started programming in MakeCode,
check out the MakeCode micro:bit website
(makecode.microbit.org). There are tutorials
and sample projects on the main page to help
you get started!
TO PROGRAM A SERVOMOTOR WITH
MAKECODE, FOLLOW THESE STEPS:
1. MakeCode has special blocks to use with
servos, but you have to add them to the list of
categories. To find them:
Go to the bottom of the category list and
select Advanced. (Figure
C
)
Scroll down to the bottom and click on
Extensions.
You’ll jump to a new page, with many
different extras you can add to MakeCode.
Look for “servo,” with a green-and-blue
drawing of a servo (Figure
D
). Click on it
and you will jump back to the MakeCode
workpage. The menu for Servos in dark
green will appear in the middle of the other
categories.
2. Open the Servos menu and drag the
set servo [P0] to [90]° block to the
workspace. Place it inside a block like on
start to activate it (Figure
E
).
3. Click on the number 90 to open a slider that
lets you rotate the servo horn to anywhere
within a half-circle (Figure
F
). Positions are
measured using a scale of zero to 180 degrees.
(The teensy circle next to the number 90 is the
90 makezine.com
E
C
D
M81_088-91_SimpRobots2_F1.indd 90M81_088-91_SimpRobots2_F1.indd 90 4/12/22 12:23 PM4/12/22 12:23 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.187.240