Microbit Trainer Training

From Wikicliki
Jump to: navigation, search

Visual Programming with Micro:bit, Tinkercademy, 7 Sept 2018

Microbit.png

  • Use Google Chrome for this: https://makecode.microbit.org/
  • This is called Block programming. You need to "snap" the part in (if audio is on, it will make a snap sound).
  • You can also use the javascript if you want to code directly.
  • Start with Forever block and plug in different blocks, such as Show Number, Show LED.
  • Then try using the buttons..

Microbitmakecode.png

Makecode1.png

Microbitlive1.jpg

Makecode3.png Makecode4.png

  • Keep the forever block
  • Good practice is to load something into on start so that you know if it is working and not a hardware issue.

Let's use the LEDs! Default values, or manually plotting X & Y Axis

Plotled0.png

Plotled1.png

X Axis

Plotled3.png

Y Axis

Plotled2.png

Inputs

Buttons

Step 1

Microbitexample 1.png

Step 2

Microbitexample 2.png

Shaking and Tilting

Step 3

Microbitexample 3.png

Touching the pins

Step 4

Microbitexample 4.png

Step 5

Microbitexample 5.png

Create variables

Simple Counter

Setvariable.png

Setvariable0.png

This only changes the variable, but doesn't show it. Something is missing here. ask the class to figure out how to "show" the number.

Setvariable1.png

Randomiser

Setmaths.png

Setvariable2.png

Setvariable3.png

Setvariable4.png

Conditionals

Make a scissors paper stone. Make micro:bit choose scissors, paper, or stone when shaken.

  • Hints: create one variable called "number"
  • Pick a random number from 0-2 so we have 3 numbers (0, 1, 2)
  • And use the If else statements

Setlogic.png

This works

Setlogicconditional.png

Improving the logic statement

Click on the Gear icon to edit the conditional statement

Setlogicconditional01.png

Setlogicconditional00.png

Setlogicconditional2.png

Scoreboard

  • Next, let's record the scores.
  • When you press A, it should add 1 to the score.
  • When you press B, it should minus 1 to the score.
  • You must have a variable called "score"

Keepscore.png


External Sensors

  • You can connect it to P0, P1, P2 with crocodile clips
  • When we read sensor info, we tend to want to do it forever

Compass

  • Must be calibrated

Microbitcompass1.jpg

Microbitcompass2.png

Microbitcompass3calibrate.jpg Microbitcompass4calibrate.jpg

Bluetooth

Bluetoothmicrobit.png

BoB Breakout Board

BOBmicrobit 1.jpg

BOBmicrobit 2.jpg

  • LEDs on the Microbit should be facing you/up when you insert it in.
  • You can connect up to 16 components.
  • You can connect more power and toggle the 3.3V and 5V switch

Speaker

  • Connect the piezo buzzer to P0

BOBmicrobitsound.png

BOBmicrobitsound1.png

Types of I/O

  • Add Potentiometer
  • Add LED
  • For this exercise, use pins 0, 1, 2. Note that for pins 4-10 the power is shared with the led and the LED on the board may show some effects.

PotSpeaker.png

Burglar Alarm

AlarmMicrobit0.png

AlarmMicrobit1.png

AlarmMicrobitYes.jpg AlarmMicrobitNo.jpg

Add Packages

Addpackagemicrobit.png

Addpackagemicrobit2.png

  • Everytime you make a new project you'll need to re-add in the packages. You are only adding to that specific project each time.
  • Use this version to generate items with the packages already loaded: http://tk.sg/pxt

Addpackagemicrobit3.png Addpackagemicrobit4.png

Scissors Paper Stone

Sps1.png

Sps2.png

Sps3.png

More resources for Microbits

Microbitprojects1.png