MICROBIT
What is Micro bit?
The Micro Bit (also referred to as BBCMicro Bit, stylized as micro:bit) is an open source hardware ARM-based embedded system designed by the BBC for use in computer education
Microbit MakeCode
Microbit makecode is a way to program a pocket-sized computer with an LED display, buttons, speaker, motion sensor and more. You can use drag-and-drop blocks, JavaScript or Python code editors to create fun projects. You can also see your code running on a virtual micro:bit simulator. Microsoft MakeCode is a block-based and text-based language that makes computer science fun and accessible.
1. Type https://makecode.microbit.org/
2. Click New Project and type the project name, then click Create button
Parts of Microbit MakeCode
Micro:bit: Return to homepage of micro:bit.
Blocks/JavaScript: Choose Blocks or JavaScript to do program and shift between these two languages.
Home: Return to homepage of micro:bit.
Share: Share your program online. You can share a web link or embedded into your website.
Help: To get help or support.
More: Project Settings, Extensions, Connect Device, Print, Delete Project, Language, Report and Reset
Sign In : Login to Microsoft or Google Account
Download: To download program into your computer or micro:bit.
Project Name: Name or Title of your project
Save: Save your project
Create GitHub Repository: A GitHub repository is a location where all the files and codes for a particular project are stored, managed, and used.
Undo and Zoom: Undo and redo your operation; zoom in or out your program bricks.
Simulator: Real-time simulator. When you change your program, the virtual micro:bit can monitor your program in real time.
Blocks: Modules used to build a program.
Code compiling interface: A place for you to write code
Components of Microbit
1. 25 LEDs: which are individually programmable
2. 2 Buttons (Button A and Button B): 2 programmable buttons labelled A and B
3. Edge Connector: To connect Pins, 3volts ad Ground
4. USB Connector: To connect interface to Computer or Laptop
5. Radio & Bluetooth: Radio and Bluetooth transmitter and receiver to let you interact with mobile devices wirelessly. A range of input and output pins to let you connect the micro:bit to other devices via it’s Edge Connector
6. Reset Button: the program or put your micro:bit to sleep to conserve power.
7. Battery Socket: In addition to USB powering, the BBC micro:bit can also be powered using a battery pack containing 2 x zinc or alkaline AAA batteries.
8. Processor: It contains an application processor with a variety of on-chip peripherals. The micro:bit has a microprocessor inside it, which is sometimes called the ‘brains’ of a computer. The processor is an essential part of the micro:bit as it runs the programs you write
9. Compass: The micro:bit has a compass sensor called a magnetometer that measures magnetic fields. It can sense the Earth’s magnetic field and so you can use it as a compass.
10. Accelerometer: An accelerometer is a motion sensor that measures movement. The Micro:bit has an accelerometer behind the B-button. The accelerometer in the BBC micro:bit detects when you tilt it left to right, backwards and forwards and up and down. The accelerometer on a BBC micro:bit measures acceleration values in the range +2g to -2g
Can you find the Processor?
• How much memory does the micro:bit have?
• Can you locate the following Inputs? Buttons (on board), Pins (at base), Accelerometer / Compass
• Where are the Outputs?
ALGORITHM
What Micro bits can DO?
● Micro bits to micro bits
● Micro bits to smart phones – real application using application (via Bluetooth)
● Playing games using micro bits and phone
● Works using accelerometers
● Using smart phone accelerometers shows emoji according to what is voiced over
● Capturing images via accelerometers
● Freefall detector for elderly/PE Students /child at home – detect free fall and sent to sms
● Can use to unlock the door
● Can put it to sleep via micro bits using programming skills
Pseudocode
What do you want your program to do?
The first step in writing a computer program is to create a plan for what you want your program to do. Write out a detailed step-by-step plan for your program. Your plan should include what type of information your program will receive, how this input will be processed, what output your program will create and how the output will be recorded or presented.
Pseudocode is like a detailed outline or rough draft of your program. Pseudocode is a mix of natural language and code.
For the program we will write, the pseudocode might look like this:
Loop Forever
2. Show LED
3. Pause 200ms
4. Clear the Screen
5. Pause 200ms
Event handlers
When you start a new project, there will be two blue blocks, ‘on start’ and ‘forever’ already in the coding workplace. These two blocks are event handlers.
In programming, an event is an action done by the user, such as pressing a key or clicking a mouse button. An event handler is a routine that responds to an event. A programmer can write code telling the computer what to do when an event occurs.
Deleting blocks
Click on the 'forever' block and drag it left to the Toolbox area. You should see a garbage can icon appear. Let go of the block and it should disappear. You can drag any block back to the Toolbox area to delete it from the coding workspace. You can also remove a block from your coding window by selecting the block and then pressing the "delete" key on your keyboard (or command-X on a mac).
Comment
It is good practice to add comments to your code. Comments can be useful in a number of ways. Comments can help you remember what a certain block of code does and/or why you chose to program something the way you did.
To comment a block of code:
Right-click on the icon that appears before the words on a block. A menu will pop up. Select ‘Add Comment’
This will cause a note icon to appear to the left of the previous icon.
Click on the note icon and a small yellow box will appear into which you can write your comment.
Save
Important: Whenever you write a significant piece of code or just every few minutes, you should save your code. Giving your code a meaningful name will help you find it faster from a list of programs and will let others know what your program does. Click the Save Icon if you want to save a copy in your drive
Block Codes
Activity # 1 - Blinking LED
Block Codes
VIDEO Tutorial
Python Script
Activity # 2 - Simple LED Animation
Block Codes
VIDEO Tutorial
Python Script
Activity # 3 - Simple Scrolling Text
Block Codes
VIDEO Tutorial
Python Script
Activity # 4 - LED Brightness
Block Codes
VIDEO Tutorial
Python Script
VARIABLES
Introduction
Computer programs that process information. Some of the information that is input, stored, and used in a computer program has a value that is constant, meaning it does not change throughout the course of the program. An example of a constant in math is ‘pi’ because ‘pi’ has one value that never changes. Other pieces of information have values that vary or change during the running of a program. Programmers create variables to hold the value of information that may change.
Variables hold a specific type of information.
The micro:bit's variables can keep track of numbers, strings, booleans, and sprites.
The first time you use a variable, its type is assigned to match whatever it is holding. From that point forward, you can only change the value of that variable to another value of that same type.
Types of Variable
A number variable could hold numerical data such as the year, the temperature, or the degree of acceleration.
A string variable holds a string of alphanumeric characters such as a person's name, a password, or the day of the week.
A boolean variable has only two values: true or false. You might have certain things that happen only when the variable called gameOver is false, for example.
A sprite is a special variable that represents a single dot on the screen and holds two separate values for the row and column the dot is currently in.
CONDITIONAL STATEMENTS
Introduction
Computer programs are instructions telling the computer how to process input and deliver output.
An important part of programming is telling the computer WHEN to perform a certain task. For this, we use something called ‘conditionals’. Conditionals get their name because a certain Condition or Rule has to be met.
These are all conditionals! Conditionals follow the format of IF this, THEN that.
IF (condition is met), THEN (action performed)
Example:IF it is snowing, THEN wear boots, ELSE wear shoes.
The ELSE portion makes sure that a different action is performed in either case. Without the ELSE action, your students might be barefoot!
Activity # 5 - Button LED On/OFF
Block Codes
VIDEO Tutorial
Python Script
Activity # 6 - Paper, Scissors & Stone
Block Codes
1. Click Input and drag on shake in Workspace
2. Click Variables, click Make a Variable…type handshake and click OK button
3. Drag set handshake to 0 inside on shake to snap and connect the block
4. Click Math and drag pick random 0 to 10 block inside 0, replace 0 to 1 and 10 to 3
5. Click Logic drag if then else block below set handshake block, click the plus symbol to add else
6. Click Logic, scroll down to comparison and drag 0=0 block inside true
7. Click Variables and drag handshake to replace 0 then change the last 0 to 1
8. Click Basic and drag show icon block below if, and change the icon to chess board
9. Click Logic, scroll down to comparison and drag 0=0 block inside else if then hexagon shape
10. Click Variables and drag handshake to 0 to else if 0=0 to make it else if handshake = 2
11. Click Basic and drag show icon block below if to snap and change the icon to scissors
12. Click the plus sign to add else condition
13. Click Basic and drag show icon block below else and change icon to square
14. Connect the Microbit using the USB cable (USB A to USB B).
15. Download the file, drag the file in the Microbit Drive
16. Test the Microbit by shaking or use the Simulator
17. Type Activity 6 - Paper, Scissors & Stone under save box and click Save button
18. Upload the file to your Google Sites > Microbit
VIDEO Tutorial
Python Script
Activity # 7 - Dice
Block Codes
VIDEO Tutorial
Python Script
Activity # 8 - Room Temperature Monitor
Block Codes
VIDEO Tutorial
Python Script
Activity # 9 - COUNTER
Block Codes
VIDEO Tutorial
Python Script
Activity # 10 - Leveler (Pitch and Roll)
Block Codes
VIDEO Tutorial
Python Script
Activity 11 - Monitor Temperature HOT and COLD
Block Codes
VIDEO Tutorial
Python Script
ITERATION
Activity 12 - ALARM
Block Codes
VIDEO Tutorial
Python Script