pxt-calliope/docs/courses/csintro/making/walkthrough.md
2017-06-23 12:58:20 -07:00

3.8 KiB
Raw Blame History

Activity: Installing a program

micro:bit activity: Installing a Microsoft MakeCode Program on the micro:bit

Objective: Learn how to download programs from the MakeCode tool.

Overview: Students will create a simple program in Microsoft MakeCode and download it to their micro:bit using a USB cable.

For this activity, students will each need a micro:bit, a micro-USB cable, a computer, and a battery pack.

micro:bit kit

Download this file to your computer (right-click, Save As):

MicroPet program

Open a browser window to makecode.com, and select the micro:bit code editor

micro:bit card icon

From the top left corner of the screen, select the Projects Menu, and click on Import File. Select the file that you saved on your computer in the previous step.

Projects folder

Import file

The program should look like the following in MakeCode. It shows a repeating series of faces:

basic.forever(() => {
   basic.showIcon(IconNames.Happy)
   basic.pause(5000)
   basic.showIcon(IconNames.Sad)
   basic.pause(5000)
})

See the MicroPet project online. https://makecode.microbit.org/_38yJ1PAkuKPV

Tour of Microsoft MakeCode

  • Simulator - on the left side of the screen, you will see a virtual micro:bit that will show what your program will look like running on a micro:bit. This is helpful for debugging, and instant feedback on program execution.
  • Toolbox - in the middle of the screen, there are a number of different categories, each containing a number of blocks that can be dragged into the programming workspace on the right.
  • Workspace - on the right side of the screen is the Programming Workspace where you will create your program. Programs are constructed by snapping blocks together in this area.

IDE tour

The color of the blocks identifies their category. All of the blocks that make up the program above come from the Basic Toolbox category, which is light blue.

Downloading a MakeCode program to the micro:bit

To download the file to your micro:bit, you must connect it to your computers USB port using a micro-USB cable. The micro:bit will draw power from your computer through the USB connection, or you can connect an optional battery pack so it can function even after it is unplugged from the computer. Once plugged in, the micro:bit shows up on your computer like a USB flash drive.

USB connection

Click the purple Download button in the lower left of the MakeCode screen. This will download the file to your computer, to the location where your browser is set to save downloads.

Download button

To move the program to your micro:bit, drag the downloaded "microbit-xxxx.hex" file to the MICROBIT drive, as if you were copying a file to a flash drive. The program will copy over, and it will begin running on the micro:bit immediately.

micro:bit drive

The micro:bit will hold one program at a time. It is not necessary to delete files off the micro:bit before you copy another onto the micro:bit; a new file will just replace the old one.

For the next project, your students should attach the battery pack (it takes 2 AAA batteries) to the micro:bit using the white connector. That way they can build it into their design without having to connect it to the computer.

Battery pack