SlideShare a Scribd company logo
1 of 40
Overview
● Introduction to BBC micro:bit
● Basic Components of micro:bit
○ Buttons
○ LED Display
○ Accelerometers
○ Radio Module
● Accessories & Add-ons
Demo
Demo
Demo
Introduction to
micro:bit
Python
Micro-
Python
Let’s Start Coding!!
Official Micro:bit
http://microbit.org/code/
Offline Alternative:
https://codewith.mu/#download
With Emulator:
https://create.withcode.uk/ Today!
https://github.com/Pyconmicrobit2017
Basic Components of
micro:bit
1
○ LED Display
○ Buttons
○ Accelerometers
○ Radio Function
Buttons
is_pressed()
Returns True if the specified button button is pressed,
and False otherwise.
was_pressed()
Returns True or False to indicate if the button was
pressed since the device started or the last time this
method was called.
get_presses()
Returns the running total of button presses, and
resets this total to zero before returning.
button_a button_b
https://create.withcode.uk/
Methods
Drawing (with LEDs)
0 1 2 3 4 5 6 7 8 9
Increasing intensity
Drawing (with LEDs)
0 1 2 3 4 5 6 7 8 9
Increasing intensity
Asteroid Game
Alarm Boxes
Lie Detectors
Music Keyboards
Blood Pressure Tester
Candy crush
Flappy Bird
● Display text
● Assign variables
● Display images
● Scroll images
● Loop
● Detect button input
display.show()
Images = Image("00003:00003:00003:00003:00003")
display.scroll()
button_a.was_pressed
while True:
frame += 1
# show pipe
display.show(i)
# flap if button a was pressed
if button_a.was_pressed():
speed = -8
# show score if button b was pressed
if button_b.was_pressed():
display.scroll("Score:" + str(score))
# accelerate down to terminal velocity
speed += 1
if speed > 2:
speed = 2
# move bird, but not off the edge
y += speed
if y > 99:
y = 99
if y < 0:
y = 0
# draw bird
led_y = int(y / 20)
display.set_pixel(1, led_y, 9)
# check for collision
if i.get_pixel(1, led_y) != 0:
display.show(Image.SAD)
sleep(500)
display.scroll("Score: " + str(score))
break
from microbit import *
import random
display.scroll("Get ready...")
# Game constants
DELAY = 20 # ms between each frame
FRAMES_PER_WALL_SHIFT = 20 # number of frames between each time a wall
moves a pixel to the left
FRAMES_PER_NEW_WALL = 100 # number of frames between each new wall
FRAMES_PER_SCORE = 50 # number of frames between score rising by 1
# Global variables
y = 50
speed = 0
score = 0
frame = 0
# Make an image that represents a pipe to dodge
def make_pipe():
i = Image("00003:00003:00003:00003:00003")
gap = random.randint(0,3) # random wall position
i.set_pixel(4, gap, 0) # blast a hole in the pipe
i.set_pixel(4, gap+1, 0)
return i
# create first pipe
i = make_pipe()
# Game loop
# move wall left
if(frame % FRAMES_PER_WALL_SHIFT == 0):
i = i.shift_left(1)
# create new wall
if(frame % FRAMES_PER_NEW_WALL == 0):
i = make_pipe()
# increase score
if(frame % FRAMES_PER_SCORE == 0):
score += 1
# wait 20ms
sleep(20)
Creation
BIRD
# Make an image that represents a pipe to dodge
def make_pipe():
i = Image("00003:00003:00003:00003:00003")
gap = random.randint(0,3) # random wall
position
i.set_pixel(4, gap, 0) # blast a hole in the
pipe
i.set_pixel(4, gap+1, 0)
return i
led_y = int(y / 20)
display.set_pixel(1, led_y,
9)
Variable y: y-position of bird
PIPE
Game mechanism
While True:
frame += 1
# move wall left
if(frame % FRAMES_PER_WALL_SHIFT == 0):
i = i.shift_left(1)
# create new wall
if(frame % FRAMES_PER_NEW_WALL == 0):
i = make_pipe()
# increase score
if(frame % FRAMES_PER_SCORE == 0):
score += 1
20
100
50
Gravity
# accelerate down to terminal velocity
speed += 1
if speed > 2:
speed = 2
#move bird
y += speed
bird
Small details to note
# flap if button a was
pressed
if button_a.was_pressed():
speed = -8
sleep(20)
Accelerometer
x= accelerometer.get_x()
y= accelerometer.get_y()
z= accelerometer.get_z()
Measuring Movement
Detecting Gestures
1.gesture= accelerometer.current_gesture()
2.if gesture == “up”
List of Gestures:
● up
● down
● left
● right
face up
face down
Freefall
shake
3g
6g
8g
5 seconds
Get into stable position
10 seconds
Deviation from x,y, z reference readings will contribute to
total points.
End
The final score is scrolled across the microbit display at the end of it.
Radio Module
1.import radio
List of Radio Functions:
● radio.on
● radio.off
● radio.reset
radio.send_bytes(message)
radio.receive_bytes()
radio.config(kwarg*)
radio.send(message)
radio.receive(message)
Radio Function
micro:bit 1 micro:bit 2
Additional Add-ons
to complement the
micro:bit
2
Siyin
wang.siyin@dhs.sg
Pearlyn
loh.woonqing.pearlyn@dhs.sg
Zixin
liu.zixin@dhs.sg
Zilong
jin.zilong@dhs.sg
Contacts
micro:bit resources
http://microbit.org/
https://github.com/bbcmicrobit/micropython
https://github.com/bbcmicrobit/PythonEditor
http://microbit.org/resellers/
Getting your own micro:bits...
(approximately USD$17 per micro:bit)
www.tinyurl.com/
pyconmicrobit

More Related Content

What's hot

Learn html Basics
Learn html BasicsLearn html Basics
Learn html BasicsMcSoftsis
 
Lecture 2 introduction to html
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to htmlpalhaftab
 
Presentation on Photoshop Tools By Batra Computer Centre
Presentation on Photoshop Tools By Batra Computer CentrePresentation on Photoshop Tools By Batra Computer Centre
Presentation on Photoshop Tools By Batra Computer CentreBatra Computer Centre
 
Third sem sample paper of 3 d animation – i bsca009
Third sem sample paper of 3 d animation – i bsca009Third sem sample paper of 3 d animation – i bsca009
Third sem sample paper of 3 d animation – i bsca009paiils111
 
Learn HTML Step By Step
Learn HTML Step By StepLearn HTML Step By Step
Learn HTML Step By StepSatish Chandra
 
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...mayank78610
 
HTML5 - Forms
HTML5 - FormsHTML5 - Forms
HTML5 - Formstina1357
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript TutorialDHTMLExtreme
 
eye phone technology
eye phone technologyeye phone technology
eye phone technologyNaga Dinesh
 

What's hot (20)

Photoshop
PhotoshopPhotoshop
Photoshop
 
Html for beginners
Html for beginnersHtml for beginners
Html for beginners
 
Intro to html
Intro to htmlIntro to html
Intro to html
 
Html Ppt
Html PptHtml Ppt
Html Ppt
 
Learn html Basics
Learn html BasicsLearn html Basics
Learn html Basics
 
Html coding
Html codingHtml coding
Html coding
 
Lecture 2 introduction to html
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to html
 
Presentation on Photoshop Tools By Batra Computer Centre
Presentation on Photoshop Tools By Batra Computer CentrePresentation on Photoshop Tools By Batra Computer Centre
Presentation on Photoshop Tools By Batra Computer Centre
 
Third sem sample paper of 3 d animation – i bsca009
Third sem sample paper of 3 d animation – i bsca009Third sem sample paper of 3 d animation – i bsca009
Third sem sample paper of 3 d animation – i bsca009
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Learn HTML Step By Step
Learn HTML Step By StepLearn HTML Step By Step
Learn HTML Step By Step
 
Web development
Web developmentWeb development
Web development
 
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...
COMPUTER HOLIDAY HOMEWORK OF HTML CODING AND OUTPUTS ON MY HOMEPAGE, FAMILY A...
 
HTML practical file
HTML practical fileHTML practical file
HTML practical file
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
HTML5 - Forms
HTML5 - FormsHTML5 - Forms
HTML5 - Forms
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 
Html presentation
Html presentationHtml presentation
Html presentation
 
Report html5
Report html5Report html5
Report html5
 
eye phone technology
eye phone technologyeye phone technology
eye phone technology
 

Similar to Programming the BBC micro:bit with MicroPython by Dunham High School

Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdffedosys
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdffatoryoutlets
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30Mahmoud Samir Fayed
 
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docx
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docxRobotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docx
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docxSUBHI7
 
Writing videogames with titanium appcelerator
Writing videogames with titanium appceleratorWriting videogames with titanium appcelerator
Writing videogames with titanium appceleratorAlessio Ricco
 
AndroidDevelopmentTrainingPortfolio
AndroidDevelopmentTrainingPortfolioAndroidDevelopmentTrainingPortfolio
AndroidDevelopmentTrainingPortfolioMaurice Moore
 
iain goodyear game engines definitions woprks 2 cristian galliano
iain goodyear game engines definitions woprks 2 cristian gallianoiain goodyear game engines definitions woprks 2 cristian galliano
iain goodyear game engines definitions woprks 2 cristian gallianocrisgalliano
 
Y1 gd engine_terminology (2)
Y1 gd engine_terminology (2)Y1 gd engine_terminology (2)
Y1 gd engine_terminology (2)crisgalliano
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - IntroductionFrancis Seriña
 
Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfacteleshoppe
 
Connor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyConnor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyKalen612
 
Game engine terminology worksheet
Game engine terminology worksheetGame engine terminology worksheet
Game engine terminology worksheetrwbybomb21
 
First fare 2010 lab-view creating custom dashboards
First fare 2010 lab-view creating custom dashboardsFirst fare 2010 lab-view creating custom dashboards
First fare 2010 lab-view creating custom dashboardsOregon FIRST Robotics
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray EnginePVS-Studio
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminologyClintParis
 

Similar to Programming the BBC micro:bit with MicroPython by Dunham High School (20)

Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdf
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdf
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
 
Pygame presentation
Pygame presentationPygame presentation
Pygame presentation
 
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docx
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docxRobotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docx
Robotics.DS_Store__MACOSXRobotics._.DS_StoreRobotics.docx
 
Writing videogames with titanium appcelerator
Writing videogames with titanium appceleratorWriting videogames with titanium appcelerator
Writing videogames with titanium appcelerator
 
2048 on swift
2048 on swift2048 on swift
2048 on swift
 
AndroidDevelopmentTrainingPortfolio
AndroidDevelopmentTrainingPortfolioAndroidDevelopmentTrainingPortfolio
AndroidDevelopmentTrainingPortfolio
 
ALU.ppt
ALU.pptALU.ppt
ALU.ppt
 
iain goodyear game engines definitions woprks 2 cristian galliano
iain goodyear game engines definitions woprks 2 cristian gallianoiain goodyear game engines definitions woprks 2 cristian galliano
iain goodyear game engines definitions woprks 2 cristian galliano
 
Y1 gd engine_terminology (2)
Y1 gd engine_terminology (2)Y1 gd engine_terminology (2)
Y1 gd engine_terminology (2)
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - Introduction
 
Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdf
 
Java swing
Java swingJava swing
Java swing
 
Connor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine TerminologyConnor martin Y1 GD Engine Terminology
Connor martin Y1 GD Engine Terminology
 
Game engine terminology worksheet
Game engine terminology worksheetGame engine terminology worksheet
Game engine terminology worksheet
 
First fare 2010 lab-view creating custom dashboards
First fare 2010 lab-view creating custom dashboardsFirst fare 2010 lab-view creating custom dashboards
First fare 2010 lab-view creating custom dashboards
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 

More from PYCON MY PLT

Train your dragons! by Shilpa Karkera
Train your dragons! by Shilpa KarkeraTrain your dragons! by Shilpa Karkera
Train your dragons! by Shilpa KarkeraPYCON MY PLT
 
Python in big data ecosystem by Nicholas Lu
Python in big data ecosystem by Nicholas LuPython in big data ecosystem by Nicholas Lu
Python in big data ecosystem by Nicholas LuPYCON MY PLT
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith YangPYCON MY PLT
 
The programmer's mind by Jessica McKellar
The programmer's mind by Jessica McKellarThe programmer's mind by Jessica McKellar
The programmer's mind by Jessica McKellarPYCON MY PLT
 
Using machine learning to try and predict taxi availability by Narahari Allam...
Using machine learning to try and predict taxi availability by Narahari Allam...Using machine learning to try and predict taxi availability by Narahari Allam...
Using machine learning to try and predict taxi availability by Narahari Allam...PYCON MY PLT
 
Data mining news articles by Amir Othman for PyCon APAC 2017
Data mining news articles by Amir Othman for PyCon APAC 2017Data mining news articles by Amir Othman for PyCon APAC 2017
Data mining news articles by Amir Othman for PyCon APAC 2017PYCON MY PLT
 

More from PYCON MY PLT (6)

Train your dragons! by Shilpa Karkera
Train your dragons! by Shilpa KarkeraTrain your dragons! by Shilpa Karkera
Train your dragons! by Shilpa Karkera
 
Python in big data ecosystem by Nicholas Lu
Python in big data ecosystem by Nicholas LuPython in big data ecosystem by Nicholas Lu
Python in big data ecosystem by Nicholas Lu
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith Yang
 
The programmer's mind by Jessica McKellar
The programmer's mind by Jessica McKellarThe programmer's mind by Jessica McKellar
The programmer's mind by Jessica McKellar
 
Using machine learning to try and predict taxi availability by Narahari Allam...
Using machine learning to try and predict taxi availability by Narahari Allam...Using machine learning to try and predict taxi availability by Narahari Allam...
Using machine learning to try and predict taxi availability by Narahari Allam...
 
Data mining news articles by Amir Othman for PyCon APAC 2017
Data mining news articles by Amir Othman for PyCon APAC 2017Data mining news articles by Amir Othman for PyCon APAC 2017
Data mining news articles by Amir Othman for PyCon APAC 2017
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 

Programming the BBC micro:bit with MicroPython by Dunham High School

Editor's Notes

  1. (zilong soften sound aft we started talking) https://github.com/Pyconmicrobit2017 https://create.withcode.uk/
  2. (Zilong) And… I will be your computing teacher for today! Behave yourselves because I am the only thing standing between you and lunch, ok? xD So why should we choose micro:bit? Well firstly, it is veeerryyy small. [hold on to a microbit] Compared to Raspberry Pi and Arduino, it is about half the size, but yet, it packs more power than the Arduino. We can use the buttons or accelerometer to give input. This is perfect to introduce beginners into the world of computing.
  3. We can code the micro:bit using the graphical Blocks Editor, but since this is PyCon, we will use MicroPython to program the micro:bit. [switch slides that show subset] It is a subset of python created specifically to run on a microcontroller. So how do we begin? [switch slides]
  4. We can start coding from the official website (http://microbit.org/code/), or if you want to do it offline, you can use https://codewith.mu/#download. But today, we are going to use the emulator on Create With Code (https://create.withcode.uk/) to show the output on the big screen. To follow along the way, you can visit this github link over here. The source codes of the demonstrations that we will be showcasing later on, are already uploaded in the github link. [switch to site] So here we are at the site, we can see 2 lines of normal python code that we are all familiar with, and a few other features here. I’m going to run the code with ctrl+enter instead of pressing the button to speed things up. I can follow the instructions and input a name and it will do exactly what the code does. But I don’t see any micro:bit here. What I’m going to do is to first import everything from microbit [from microbit import *]. We know that microbit only have a small 5 by 5 display. So, we need to change the print function into display.scroll. I run the file again and input the name. Now you can see the words being displayed by scrolling through the display We have the output done. But our input is still a text box. While you can do this on the emulator, there isn’t really a textbox for you to fill in when you are dealing with the microbit in real life. So what inputs do we have? Now I will invite my colleague up…
  5. (Pearlyn) Thank you Zilong. For the next segment, we will be looking at some of the basic components of micro:bit. Thus far, we have written some codes that make the micro:bit do something and produce some output. But what about getting the microbit to react and receive inputs? In normal programs, users enter input using the keyboard. For the micro:bit: we don't really see any keyboard... But we do see something else… [next slide]
  6. (Pearlyn) In micro:bit, the most obvious mean of input will be these 2 buttons labelled A and B here. Pressing these buttons is equivalent to inputting values. In this case, a True value if the button is pressed, and a False value otherwise.
  7. (Pearlyn) Besides is_pressed, we have other functions such as was_pressed and get_presses. As their names imply, was_pressed checks if the button was pressed since run-time. And if it was, a true value will be returned. Else, a false value will return. The function get_presses() however, has 2 functions. Firstly, it returns to us the total number of button presses. Secondly, it resets this total to a zero before returning. So, how do we get MicroPython to react to these buttons? It’s simple, like A,B,C actually. In fact, it’s exactly what I just said in English! Let’s go through this once by running through a quick code together (zilong switch to sites to do live code1)
  8. (Zixin) To understand the following game, first we will start off with the basic concept of creating a variable, which in this case will be named ‘test’ and assign a respective image to it. Note that ‘Image’ is a built-in function in micro-python, and it takes arguments from left to right, top row to bottom row to create a 5 x 5 grid of varying intensities, with value 0 being lowest,or off, and 9 being the brightest. Hence, if I use display.show(Image( '07070:00000:00400:60006:06660')), can anyone guess what this is? Yep thats right, its a smiley face, Similarly, you can create an budget eiffel tower here or paint some abstract art with these functions, you can create endless images up to your imagination!
  9. (Zixin) To understand the following game, first we will start off with the basic concept of creating a variable, which in this case will be named ‘test’ and assign a respective image to it. Note that ‘Image’ is a built-in function in micro-python, and it takes arguments from left to right, top row to bottom row to create a 5 x 5 grid of varying intensities, with value 0 being lowest,or off, and 9 being the brightest. Hence, if I use display.show(Image( '07070:00000:00400:60006:06660')), can anyone guess what this is? Yep thats right, its a smiley face, Similarly, you can create an budget eiffel tower here or paint some abstract art with these functions, you can create endless images up to your imagination!
  10. For example, we can create a simple asteroid game using some python and a few minutes. To make a beautiful painting, we first need to have an empty canvas, and that is the same for python. For creating the game background for it to play on, we will first have to initialise a set of grids. Let us briefly import the microbit library, and the random module here to create the positions of the asteroids, because a game where the asteroids fall from only one place would be a bit boring to say the least. Since python is an object-oriented programming language, we will start by defining 2 variables, the asteroids, and the spaceship, as each holding a different value. So, after we define the variables, the asteroids, being generated at random, will move down every 0.7s in successive motion or through what we call loops. So grid 3, being the top grid, would be shifted down to the 2nd grid, and the 2nd grid would be shifted down to the first grid, down to 0. In doing so, the integer values each asteroid carries are carried over to the subsequent grid, thus forming a moving frame. And eventually right before the end of a loop, if the asteroid is right on top of the spaceship, then at the next instance, the value of asteroid that will carried downwards will not tally with the initial value of the spaceship grid, and if we look at line 13, if the value of the grid on top of the spaceship is 4, which is the inherent value of asteroids, it would be different from the 9 that the spaceship holds. And thus it will issue a ‘break’ command and the game will end. Simple as that.
  11. (Zixin) This game uses an accelerometer to sense movement and angular rotations, but that is just one of many tools we can incorporate into microbits. Microbits can also be connected to buzzers, passive infrared sensors, crash sensors, to create, alarm boxes, lie detectors, blood pressure tester, mini gameboys, percussion instruments, music game keyboard, who knows? It creates endless possibilities to benefit human lives, and that is up to you all to figure out.
  12. We have covered buttons, led displays, and input/outputs. If we take a closer look here, we notice that there’s something called the accelerometer here. As its name suggests, an accelerometer measures instaneous acceleration of the micro:bit in units of milli-gals (gals are simply units of acceleration). So what does the accelerometer do? The accelerometer has 2 functions, to either 1. Measure movement or 2. Detect Gestures.
  13. Firstly, the accelerometer measures movement along three axes: X - tilting from left to right. Y - tilting forwards and backwards. Z - moving up and down To get the positions, we can do a simple “get_y”method for the y-axis or “get_z” for the z axis. Most accelerometers either has two axis or three axis. The benefits of having 3 axis like that of micro:bit would mean we can get a more accurate 3D positioning and comprehensive movement of the microbit, opening up a new box of possibilities to explore with the micro:bit. The really interesting side-effect of having such a 3 axis accelerometer is the ability to detect gesture gesture detection. (nxt slide)
  14. If you move your micro:bit in a certain way (as a gesture) then MicroPython is able to detect this. All we have to do is to call the accelerometer object at the start (accelerometer._____) and micropython will be able to recognise the following gestures: up, down, left, right, face up, face down, freefall, 3g, 6g, 8g, shake. This would be a much more convenient way rather than constantly toggling with x,y,z values. Do take note that gestures are always represented as strings. The names of the gestures are pretty self- explanatory- (up down, left right) 3g, 6g and 8g gestures would refer to when the micro:bit encounters such levels of g-force (like when an astronaut is launched into space). Similarly to the x,y, z positions, to get the current gesture, we first call the accelerometer object, then we a current_gesture method. Now that we’ve learned the accelerometer module and have some knowledge of the input/ output function in MicroPython for micro:bit, let’s move on to how it can possibly be applied in the real world. For that, I will be showcasing to you one of the projects my teacher undertook for the Dunman High Air Weapons Club.
  15. This was coded by one of our teachers for the Air Weapons Club. As Microbit has a built-in accelerometer, this device captures the data calculated by the accelerometer when it starts. The user has 5 seconds to get into a stable position. This is equivalent to adopting the aiming phase of air pistol shooting. The 5 seconds is marked by a countdown "clock" displayed on the microbit. (press reset)
  16. At 5 seconds, the x, y and z of the accelerometer measurement are taken as the reference readings.
  17. For the next 10 seconds, any deviation from the x, y and z reference readings will contribute points to the total score The lower the total score, the better the user is able to maintain her balance.
  18. The final score is scrolled across the microbit display at the end of it.
  19. Micro:bits are like computers, just, much more smaller. And without a keyboard and a screen. But! Like computers, it has the ability to connect devices together via simple wireless networks. How? (nxt slife) Through the radio module! Because it’s a built-in module, we would have to first access the module using “import radio” From there, the radio has several functions: Today we will jus be focussing on radio.send and radio.receive
  20. Going back to the demonstration i’ve just shown, the radio module can actually be applied here. In this case, the radio module is programmed into a separate microbit to remotely restart the trial. 1 microbit sends signal, and the other receives. This way, the coach can actually use the microbit 1 to simultaneously restart a set of 5, or more, microbits at the same time. And that’s it for the radio :) To piece things together, we have looked at the basic components of microbit, namely the buttons, display, accelerometer and radio function. These are really simply the building blocks of any microbit programme and there is much much more to uncover. I hope this segment gave you a better understanding of the basic functions of microbits. For now, I will invite Siyin to do a final demo on how we can extend these basic functionalities of microbit by connecting it with additional accessories. I will now have zixin to wrap things up!,
  21. (Siyin)
  22. The first one provides a comprehensive overview on the use of microbits, where to buy them, and how to incorporate them into our daily lives if you are feeling extra creative. The second is a Singapore-based company, which provides public courses, along with blogs and documentations, for people of all walks of life to explore microbits. The 3rd and 4th are part of the Microbit Open Source Project (MOSP), which aims to keep micropython and codes for related microbit projects available to everyone, so as to hopefully add on to one another’s ideas and create positive, meaningful changes to this world.
  23. (zIXIN) Now, after you have discovered the various uses and potentials of microbits, you might be wondering where can I possibly purchase them? Well worry no more, as this website provides you with more than enough information over Asia Pacific, from ICOSA tech in Malaysia, to TinkerAcademy in Singapore, to Classroom in China. along with https://gethacking.com/products/micro-bit-tinker-kit (Shipping to Malaysia and Indonesia available)