Let’s get started
Attach USB cable to the top of micro:bit and plug in laptop USB port. The LED lights will flash and scroll the word ‘Hello’.
Press buttons as indicated by ‘A’ and ‘B’.
Shake: Fill the screen with dots.
The accelerometer can detect some of the forces that are acting on it. In this case, if you are shaking it (it can also detecting if it’s upside down) . You can write a program for micro:bit that will tell you how high you threw your it into the air!
Chase the Dot: Move the steady dot by tilting your BBC micro:bit. Catch the flashing dot. Now do it again a few times and you’re done.
Eject BBC micro:bit
MakeCode
Open app
Click shortcut on taskbar.
(Alternatively, access the program through a browser at makecode.microbit.org)
Select ‘New Project’
Coding options
- Block
- JavaScript
Functions
Blocks ‘Basics’
Adding blocks
- Open section
- Find block
- Drag and drop to canvas
Deleting blocks
- Select blocks to delete
- Drag and drop blocks to functions
- Deposit in ‘Trash’
JavaScript
LED Heart
Try some more shapes
Set ‘Heart’
- Go back to set the Heart shaped icon.
Save
- Give the file a name
- Click ‘Save’ icon
Download program to BBC micro:bit
Connect micro:bit to laptop with micro USB cable.
There are two options for downloading a file to the micro:bit device:
- Direct download
- Transfer saved file (Flashing)
Direct download
Select ‘Download’
Heart icon will appear on the micro:bit’s LED lights.
Try other icons
- Change icon shape
- Download to BBC micro:bit
Transfer saved file (Flashing)
Files can be transferred directly to a micro:bit in the format of a .HEX file. This process is called ‘flashing’.
Flash memory
- Solid State Drive (SSD) chip that stores digital data. ‘Solid State’ means there are no moving parts
- Non-volatile, meaning it remains when a device powers down
Flash memory is commonly used in portable electronics and removable storage devices, such as:
- Smartphones
- GPS
- MP3 players
- Laptops/tablets
- USB drives
- Digital cameras
- BBC micro:bits
A quick reminder about computer memory
There are two types of memory in computers:
Random Access Memory (RAM):
- ‘forgets’ information when switched off
- stored information can be re-written
- temporary storage
- fast access
Read-Only Memory (ROM):
- ‘remembers’ information
- stored information can’t be written (like the operating system)
- permanent storage (hard drives)
- slow access
Flash memory has certain things in common with both RAM and ROM. Like ROM, it remembers information when the power is off; like RAM, it can be erased and rewritten over and over again.
Where does the name come from?
Literally, an electrical charge ‘flashes’ across the circuit. The flow of electrons determines whether a ‘1’ or ‘0’ is recorded.
Binary Code
Binary code is the simplest form of code, represented entirely by a string of consecutive 0s and 1s. Patterns of 0s and 1s, also known as bits, are assigned to characters, instruction, etc., that computers can understand.
Did you know? The modern binary number system, the basis for binary code, was invented in 1689!
.HEX files
Remember we said files can be transferred directly to a micro:bit in the format of a .HEX file.
Standing for ‘Intel hexadecimal object’ file format (or Intel hex format or Intellec Hex), this is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, like the BBC micro:bit.
Flashing
To flash the .HEX file, simply drag and drop it on to the micro:bit drive.
The LED on the back of your BBC micro:bit flashes during the transfer (which should only take a few seconds).
Once transferred, the code will run automatically on your BBC micro:bit. To rerun your program, press the reset button on the back of your BBC micro:bit. The reset button automatically runs the newest file on the BBC micro:bit.
By copying the program onto the MICROBIT drive, you have programmed it into the flash memory on the micro:bit, which means even after you unplug the micro:bit, your program will still run if the micro:bit is powered by battery.
Transfer the ‘Heart’ file
This is a two-step process:
1. Go to the Downloads folder
2. Drag an drop the Heart file to the
Factory reset
To wipe a micro:bit’s memory, find the file titled ‘OutOfBoxExperience’.
Drag and drop it onto the MICROBIT drive.
The micro:bit’s LED lights will show the original ‘Hello’ program.
© Code Champions, March 2020