Coding with micro:bits

What is a micro:bit?

Micro:bit is a tiny programmable computer. It was designed by the BBC for use in computer education in the UK.

Microsoft MakeCode is a free, open-source Block and JavaScript learn-to-code editor. It has a drag and drop interface. Blocks snap together to build program which are downloaded to the micro:bit.

It's a great introduction to physical programming for those with little or no experience.

http://microbit.org/

https://www.makecode.com/

*The front of a micro:bit has the colored micro:bit symbol.

*The yellow LED on the back of the micro:bit will blink while your code is uploading.

-----------------------------------------------------------------------------------

The micro:bit components:

a 5x5 LED display (25 lights)

accelerometer

compass

buttons

I/O pins,

Micro USB plug

Bluetooth Low Energy antenna

ARM Cortex-M0 processor

battery plug

(Source)

micro:bit history and information

A micro:bit is a small pocket-sized computer which can empower students to learn programming, coding, and computational creative physical computing.

1. A Brief History

    1. 1980s: BBC Computer Literacy Project
    2. 2015: BBC “Make It Digital” Initiative
    3. 29 partners developed, manufactured, delivered
    4. March 2016: delivered to young people in the UK
    5. Oct 2016: micro:bit foundation was born
    6. 2017: worldwide distribution

2. Embraced globally

    1. 90% - anyone can code
    2. 86% - computer science more interesting
    3. Increase in teacher confidence

3. Kick Start Curiosity with a micro:bit

    1. Hands On
    2. Learn the basics of computational thinking
    3. Kid resistant not kid proof
    4. Different colors - random
    5. Track gforce- shake it, compass - detects magnetic field
    6. Can detect a magnet like with the shell game (Find the magnet under the cup)
    7. Hook up buzzers and sensors
    8. Has a radio on it (so it can talk to other micro:bits)
    9. Do not have to handle gently, you can touch it

10. Uses Microsoft web-based, free software (works on Mac, PC and Chromebook - works in a pinch of iPad (it is getting better)

Let's Get Started, part 1: What's in the purple container?

Pick up your box of micro:bit components. You can find a list of all items in the document included in your bag. Below is a list of everything that should be in there:

  1. micro:bit — The brains of the outfit with a bunch of on-board components.
  2. USB micro-B Cable: This 6-foot cable provides you with a USB-A connector at the host end and standard B connector at the device end.
  3. Two Alligator Test Leads: A great way to connect individual components to the micro:bit ring connectors.
  4. Piezo Buzzer: BUZZZZ! Used to make different frequencies of sound.

Let's Get Started, part 2: The process of downloading your program into the micro:bit

Step 1: Get your materials out of the purple container. (Group Project 1)

Step 2: Go to: https://makecode.microbit.org/ and choose micro:bit.

Step 3: Plug the micro:bit into the mini USB cable. Plug the USB cable into your computer.

Step 4: Click on new project.

Step 5: Enter a name for our project in the Untitled Box.

Step 6: Click the blue save button

Step 7: Enter the code on the task card or write your own code.

Step 8. Click on download.

Step 9: Locate the .hex file and choose the following option for your device:

  • WINDOWS > Save to your desktop. Right Click on the .hex file and send it to the micro:bit
  • MAC > Drag your .hex file into the micro:bit. Wait for the sound and your file will run.
  • CHROMEBOOK > Drag the hext file on the USB icon on the desktop.

Step 10: Once the code is uploaded your code will run.

Projects

#1 - Scroll your Name & Icon

Create a program that displays your first name once, then flashes a symbol.

Blocks in Basic

Select show string and show icon

Follow directions above to download program to the micro:bit

#2 - Q & A with micro:bit

The micro:bit will give your answer.

Blocks in Basic and Input

Press button A, display your icon for yes

Presses button B, display your icon for no

Extension: Can you add code for maybe?

#3 - Happy Face/Sad Face

Create a program that displays a happy face/sad face based on the button you press.

Blocks in Basic and Input (show leds)

Whenever the user presses button A, display a happy face.

Whenever the user presses button B, display a sad face.

Bonus:

Code an expression when both A and B are pressed.

#4 - The Beat Goes On

Create a program to flash a heart 5 times

Blocks in Basic, Input and Loops

Set up your program to start your program when A+B are pressed

Create your two heart design with show leds

Repeat your flashing heart 5 times

#5 - CHARGE!

Let's program the micro:bit for a competition standard call to action.

Blocks in Input and Music

Set up your code to run with an input

Use the music blocks to code CHARGE

**In order for the micro:bit to make sound, you will need to add connect the buzzer with the alligator clips

For other songs - scroll to the bottom.

#6 - Rock - Paper - Scissors

Use the accelerometer and the screen to build a Rock Paper Scissors game that you can play with your friends!

1. write the code

2. find your opponent - play

3. if you lose, you become the cheerleader and we go around the room until the last 2 standing

Use Blocks in Input, Variable, Logic and Basic to build the Game

On shake from Input

Make a Variable - name the variable tool

Add the Set Block

Math Random Bock 0-10 - change to 0-2

Get logic (If This/Then)

#7 Create a Compass

Feeling adventurous? Try coding your own compass.

The Code

  1. If compass degrees are less than 45 degrees or greater than 315, show North ("N")
  2. If compass heading is less than 135 degrees, show East ("E") on micro:bit
  3. If degrees are less than 225, show South ("S")
  4. Otherwise, show West ("W") on micro:bit

Code?

  • Hint: There's a compass project. Read this blog entry to give you more background. You'll learn more if you try to recreate the code rather than just save the existing code link.

#8 Math Game from Melba - Salute

https://makecode.microbit.org/projects/salute

Melba introduced us to this fantastic math game using micro:bits (5th and 6th graders)

Salute! is a simple math game where players select a number card from a deck (without looking at it) and hold it to their forehead as in a “salute”. Another player decides whether to make a sum or product of the two cards and then announces the result. Based on the card held by the opposing player and the result announced, each player tries to figure out what card they are holding.

Micro:Bit Resources

More Music

Hot Cross Buns

Amazing Grace

Mary Had a Little Lamb