SlideShare a Scribd company logo
micro:bit
JavaScript meets microcontroller
Kenneth Geisshirt
geisshirt@gmail.com
Svante Geisshirt
svante2001@gmail.com
Agenda
● What is micro:bit?
● Not only JavaScript
● Setting up your environment
● Programming
● Resources
● Demo 😱
What is
micro:bit?
BBC’s take on STEM
● BBC tries to promote Science, Technology, Engineering and Mathematics
(STEM)
● Targeting 11-12 years old children
● Transformation from consumer to designer/developer/producer
● Organized in Microbit Educational Foundation
○ 20+ partners
A little history lesson
● Developed by BCC
● Introduced in 1981
● Featured in BBC’s The Computer Programme
● Heavily used in schools in UK
● Manufactured by Acorn
○ Acorn later designed Acorn Risc Machine
○ And later changed its name to ARM
● BASIC as main programming language
Hardware
● 16 MHz ARM Cortex-M0 (32 bit)
● 256 KB flash + 16 KB memory
● 2.4 LE Bluetooth
● MicroUSB port
● 5×5 LED array (display)
● 1 reset button + 2 user buttons
● 3-axis accelerometer
● 3-axis magnetometer
● 3× I/O ports (0-2), 3V and GND with crocodile clip)
● Edge connector Power-Width Modulator (PVM) and
General-Purpose I/O (GPIO)
Block programming
● Web based development
environment
● Simple blocks instead of text
● Blocks for
○ Loops and branches
○ Reacting to events (pressing a
buttons, etc.)
○ Writing to the display (5×5 LEDs)
● Built-in simulator
● Community contributed blocks
3rd party kits
● Educational kits
○ Resistors, battery pack, LEDs
● Robotics kits
○ Motor drivers, motors
● Game console kits
○ Joystick, buttons
● IoT kits
○ Sensors
● Many home brew projects
DR ultrabit
● Danmark’s initiative to promote STEM
● Target: 4. - 6. grade (9 - 11 years)
● 90 % of all 4. graders received a kit in
2018!
● Curriculum/projects adapted to Danish
schools (or at least translated from English)
● TV programmes (channel DR ultra)
● 15+ partners
● Financially supported by Industriens Fond
● Running for at least three years
● micro:bit (of course!)
● Crocodile bites
● Battery pack
● Red, green and yellow LEDs
● Buzzer
● Copper tape
Not only
JavaScript
MicroPython
● MicroPython is a special edition of Python
● Originally targeting IoT devices
● Compiles Python 3.4 and some Python 3.5
to ARM, Arduino, ESP8266, ESP32, and
micro:bit
● Threads are supported
● Some standard modules are implemented
● Only a limited set of data types are
supported
from microbit import *
intensity = 0
while True:
if button_a.is_pressed():
intensity += 25
if intensity > 1023:
intensity = 1023
if button_b.is_pressed():
intensity -= 25
if intensity < 0:
intensity = 0
display.scroll(intensity)
pin0.write_analog(intensity)
And a few others
● C++ is officially supported
○ Using either GCC or ARMCC as toolchain
○ Direct access to runtime library
● Arduino
○ C/C++ and runtime
● Pascal, Lisp, Forth and Ada are alternative
languages
● Scratch 3 (block programming for kids) can
be used
● Simulink (block programming for Matlab
users)
Setting up your
environment
Programming Experience Toolkit (pxt)
● Provided by Microsoft
● Easy to install (for node users)
○ npm install -g pxt
● Command-line interface
● Tight integration with Visual Studio Code
○ Terminal → Run Task
● Includes a simulator (but is hard to get to
work)
● Much of the runtime library is written in C++
A new project
● Creating a new project
○ mkdir my-microbit-app && cd my-microbit-app
○ pxt target microbit - set platform
○ pxt init - create a skeleton project with VSCode integration
○ pxt npminstallnative - install basic packages
● Building your project
○ pxt build
● Run on a real device
○ pxt deploy
● Start simulator and run app
○ pxt serve
○ pxt run
Programming
Static TypeScript
● Subset of TypeScript v2.6
○ Most rookie code is plain JavaScript
● The usual types including strings and arrays
● any is not supported
● Generic functions cannot be values
● pxt compiles static TS to ARM assembler
○ Take a look in built/binary.hex
A rich runtime library
● The core library includes a number of modules
○ basic - the most common functions
○ input - various input functions (buttons, gestures, …)
○ control - spawning threads and manipulation of
events
○ music - play tones using a set of attached
headphones
○ serial - write strings and numbers to the serial port
(useful when debugging
○ console - the usual logging function
○ led - control the 5×5 display
basic.forever(function () {
led.toogle(3, 3)
basic.pause(1000)
})
let freq = 440
for (let i = 0; i < 5; i++) {
freq = i * freq
music.playTone(freq, 1000)
}
Input and output
input.onButtonPressed(Button.A, function () {
intensity += 25
if (intensity > 1023) {
intensity = 1023
}
})
basic.showNumber(intensity)
pins.analogWritePin(AnalogPin.P0, intensity)
serial.writeNumber(intensity)
Register a handler to process
input events
Output through plain function
calls
Multitasking and events
● control.inBackground() spawns a
new thread
● basic.forever() executes the same
thread indefinitely
● Thread runs until it gives up the CPU -
cooperative multitasking
○ Calling basic.pause() will release the
CPU
● I/O events interrupts any running thread
○ So you won’t miss
input.onButtonPressed()
● control.raiseEvent() emits an event
● control.onEvent() registers an event
handler
● You can listen for system events
● Or create your own events
Urs Steiner, https://www.flickr.com/photos/stoneysteiner/
Multitasking and events - example
let numberOfEvents = 0;
control.onEvent(EventBusSource.MES_BROADCAST_GENERAL_ID, 0,function () {
basic.showNumber(numberOfEvents);
});
control.inBackground(function () {
while (true) {
numberOfEvents++;
control.raiseEvent(EventBusSource.MES_BROADCAST_GENERAL_ID,
0, EventCreationMode.CreateAndFire);
basic.pause(1000);
}
});
basic.forever(function () {
serial.writeNumber(numberOfEvents);
basic.pause(2000);
});
Resources
Resources
● Microbit Educational Foundation
○ https://microbit.org
● DR Ultrabit
○ https://www.dr.dk/om-dr/ultrabit
○ https://www.dr.dk/skole/ultrabit
● micro:mag
○ https://www.micromag.cc
● pxt
○ https://github.com/Microsoft/pxt
● Shops
○ https://raspberrypi.dk
○ https://elextra.dk
Abington Free Library,
https://www.flickr.com/photos/abingt
onroslynlibraries/
https://microbit.hackster.io/rypsmith/micr
o-bit-moisture-sensor-a6909c
Time for a demo

More Related Content

Similar to micro:bit and JavaScript

Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
Venkata Sai Vamsi Penupothu
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
rajalakshmi769433
 
Python for PHP developers
Python for PHP developersPython for PHP developers
Python for PHP developers
bennuttall
 
BeagleBone black
BeagleBone blackBeagleBone black
BeagleBone black
Raja Vedula
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
KeatonParker2
 
Pre meetup intel® roadshow london
Pre meetup intel® roadshow londonPre meetup intel® roadshow london
Pre meetup intel® roadshow london
Hugo Espinosa
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
Phil Eaton
 
Ake hedman why we need to unite and why vscp is a solution to a problem
Ake hedman  why we need to unite and why vscp is a solution to a problemAke hedman  why we need to unite and why vscp is a solution to a problem
Ake hedman why we need to unite and why vscp is a solution to a problem
WithTheBest
 
Iot with-the-best & VSCP
Iot with-the-best & VSCPIot with-the-best & VSCP
Iot with-the-best & VSCP
Ake Hedman
 
Software maintenance PyConUK 2016
Software maintenance PyConUK 2016Software maintenance PyConUK 2016
Software maintenance PyConUK 2016
Cesar Cardenas Desales
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
ICS
 
Combining Machine Learning with Physical Computing - June 2022
Combining Machine Learning with Physical Computing - June 2022Combining Machine Learning with Physical Computing - June 2022
Combining Machine Learning with Physical Computing - June 2022
Hal Speed
 
Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)
Aravind E Vijayan
 
Blinky 101 with Arduino v1.0b3 (FastLED)
Blinky 101 with Arduino v1.0b3 (FastLED)Blinky 101 with Arduino v1.0b3 (FastLED)
Blinky 101 with Arduino v1.0b3 (FastLED)
kriegsman
 
Indroduction arduino
Indroduction arduinoIndroduction arduino
Indroduction arduino
ThingerbitsElectroni
 
Indroduction the arduino
Indroduction the arduinoIndroduction the arduino
Indroduction the arduino
Hasarinda Manjula
 
PIC18F458_Ritula Thakur.pptx.pdf
PIC18F458_Ritula Thakur.pptx.pdfPIC18F458_Ritula Thakur.pptx.pdf
PIC18F458_Ritula Thakur.pptx.pdf
AvinashJain66
 
Socket Programming with Python
Socket Programming with PythonSocket Programming with Python
Socket Programming with Python
GLC Networks
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptx
Akshat Bijronia
 
Chapter+1 +the+adventure+begins
Chapter+1 +the+adventure+beginsChapter+1 +the+adventure+begins
Chapter+1 +the+adventure+begins
noor020202
 

Similar to micro:bit and JavaScript (20)

Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 
Python for PHP developers
Python for PHP developersPython for PHP developers
Python for PHP developers
 
BeagleBone black
BeagleBone blackBeagleBone black
BeagleBone black
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
 
Pre meetup intel® roadshow london
Pre meetup intel® roadshow londonPre meetup intel® roadshow london
Pre meetup intel® roadshow london
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Ake hedman why we need to unite and why vscp is a solution to a problem
Ake hedman  why we need to unite and why vscp is a solution to a problemAke hedman  why we need to unite and why vscp is a solution to a problem
Ake hedman why we need to unite and why vscp is a solution to a problem
 
Iot with-the-best & VSCP
Iot with-the-best & VSCPIot with-the-best & VSCP
Iot with-the-best & VSCP
 
Software maintenance PyConUK 2016
Software maintenance PyConUK 2016Software maintenance PyConUK 2016
Software maintenance PyConUK 2016
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
Combining Machine Learning with Physical Computing - June 2022
Combining Machine Learning with Physical Computing - June 2022Combining Machine Learning with Physical Computing - June 2022
Combining Machine Learning with Physical Computing - June 2022
 
Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)
 
Blinky 101 with Arduino v1.0b3 (FastLED)
Blinky 101 with Arduino v1.0b3 (FastLED)Blinky 101 with Arduino v1.0b3 (FastLED)
Blinky 101 with Arduino v1.0b3 (FastLED)
 
Indroduction arduino
Indroduction arduinoIndroduction arduino
Indroduction arduino
 
Indroduction the arduino
Indroduction the arduinoIndroduction the arduino
Indroduction the arduino
 
PIC18F458_Ritula Thakur.pptx.pdf
PIC18F458_Ritula Thakur.pptx.pdfPIC18F458_Ritula Thakur.pptx.pdf
PIC18F458_Ritula Thakur.pptx.pdf
 
Socket Programming with Python
Socket Programming with PythonSocket Programming with Python
Socket Programming with Python
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptx
 
Chapter+1 +the+adventure+begins
Chapter+1 +the+adventure+beginsChapter+1 +the+adventure+begins
Chapter+1 +the+adventure+begins
 

More from Kenneth Geisshirt

Building parsers in JavaScript
Building parsers in JavaScriptBuilding parsers in JavaScript
Building parsers in JavaScript
Kenneth Geisshirt
 
Open Source in Real Life
Open Source in Real LifeOpen Source in Real Life
Open Source in Real Life
Kenneth Geisshirt
 
Building mobile apps with Realm for React Native
Building mobile apps with Realm for React NativeBuilding mobile apps with Realm for React Native
Building mobile apps with Realm for React Native
Kenneth Geisshirt
 
Tales from the dark side: developing SDKs at scale
Tales from the dark side: developing SDKs at scaleTales from the dark side: developing SDKs at scale
Tales from the dark side: developing SDKs at scale
Kenneth Geisshirt
 
Android things
Android thingsAndroid things
Android things
Kenneth Geisshirt
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
Kenneth Geisshirt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
Kenneth Geisshirt
 
Is the database a solved problem?
Is the database a solved problem?Is the database a solved problem?
Is the database a solved problem?
Kenneth Geisshirt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
Kenneth Geisshirt
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
Kenneth Geisshirt
 
Sociale netværk
Sociale netværkSociale netværk
Sociale netværk
Kenneth Geisshirt
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Naturvidenskabsfestival 2012
Naturvidenskabsfestival 2012Naturvidenskabsfestival 2012
Naturvidenskabsfestival 2012Kenneth Geisshirt
 
Hadoop - the data scientist's toolbox
Hadoop - the data scientist's toolboxHadoop - the data scientist's toolbox
Hadoop - the data scientist's toolbox
Kenneth Geisshirt
 
JavaScript/Emacs integration
JavaScript/Emacs integrationJavaScript/Emacs integration
JavaScript/Emacs integrationKenneth Geisshirt
 
Introduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software DevelopmentIntroduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software Development
Kenneth Geisshirt
 
Kendthed og vigtighed
Kendthed og vigtighedKendthed og vigtighed
Kendthed og vigtighed
Kenneth Geisshirt
 

More from Kenneth Geisshirt (19)

Building parsers in JavaScript
Building parsers in JavaScriptBuilding parsers in JavaScript
Building parsers in JavaScript
 
Open Source in Real Life
Open Source in Real LifeOpen Source in Real Life
Open Source in Real Life
 
Building mobile apps with Realm for React Native
Building mobile apps with Realm for React NativeBuilding mobile apps with Realm for React Native
Building mobile apps with Realm for React Native
 
Tales from the dark side: developing SDKs at scale
Tales from the dark side: developing SDKs at scaleTales from the dark side: developing SDKs at scale
Tales from the dark side: developing SDKs at scale
 
Android things
Android thingsAndroid things
Android things
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
Is the database a solved problem?
Is the database a solved problem?Is the database a solved problem?
Is the database a solved problem?
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 
Sociale netværk
Sociale netværkSociale netværk
Sociale netværk
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Naturvidenskabsfestival 2012
Naturvidenskabsfestival 2012Naturvidenskabsfestival 2012
Naturvidenskabsfestival 2012
 
Hadoop - the data scientist's toolbox
Hadoop - the data scientist's toolboxHadoop - the data scientist's toolbox
Hadoop - the data scientist's toolbox
 
JavaScript/Emacs integration
JavaScript/Emacs integrationJavaScript/Emacs integration
JavaScript/Emacs integration
 
Introduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software DevelopmentIntroduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software Development
 
Kendthed og vigtighed
Kendthed og vigtighedKendthed og vigtighed
Kendthed og vigtighed
 

Recently uploaded

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

micro:bit and JavaScript

  • 1. micro:bit JavaScript meets microcontroller Kenneth Geisshirt geisshirt@gmail.com Svante Geisshirt svante2001@gmail.com
  • 2. Agenda ● What is micro:bit? ● Not only JavaScript ● Setting up your environment ● Programming ● Resources ● Demo 😱
  • 4. BBC’s take on STEM ● BBC tries to promote Science, Technology, Engineering and Mathematics (STEM) ● Targeting 11-12 years old children ● Transformation from consumer to designer/developer/producer ● Organized in Microbit Educational Foundation ○ 20+ partners
  • 5. A little history lesson ● Developed by BCC ● Introduced in 1981 ● Featured in BBC’s The Computer Programme ● Heavily used in schools in UK ● Manufactured by Acorn ○ Acorn later designed Acorn Risc Machine ○ And later changed its name to ARM ● BASIC as main programming language
  • 6. Hardware ● 16 MHz ARM Cortex-M0 (32 bit) ● 256 KB flash + 16 KB memory ● 2.4 LE Bluetooth ● MicroUSB port ● 5×5 LED array (display) ● 1 reset button + 2 user buttons ● 3-axis accelerometer ● 3-axis magnetometer ● 3× I/O ports (0-2), 3V and GND with crocodile clip) ● Edge connector Power-Width Modulator (PVM) and General-Purpose I/O (GPIO)
  • 7. Block programming ● Web based development environment ● Simple blocks instead of text ● Blocks for ○ Loops and branches ○ Reacting to events (pressing a buttons, etc.) ○ Writing to the display (5×5 LEDs) ● Built-in simulator ● Community contributed blocks
  • 8. 3rd party kits ● Educational kits ○ Resistors, battery pack, LEDs ● Robotics kits ○ Motor drivers, motors ● Game console kits ○ Joystick, buttons ● IoT kits ○ Sensors ● Many home brew projects
  • 9. DR ultrabit ● Danmark’s initiative to promote STEM ● Target: 4. - 6. grade (9 - 11 years) ● 90 % of all 4. graders received a kit in 2018! ● Curriculum/projects adapted to Danish schools (or at least translated from English) ● TV programmes (channel DR ultra) ● 15+ partners ● Financially supported by Industriens Fond ● Running for at least three years ● micro:bit (of course!) ● Crocodile bites ● Battery pack ● Red, green and yellow LEDs ● Buzzer ● Copper tape
  • 11. MicroPython ● MicroPython is a special edition of Python ● Originally targeting IoT devices ● Compiles Python 3.4 and some Python 3.5 to ARM, Arduino, ESP8266, ESP32, and micro:bit ● Threads are supported ● Some standard modules are implemented ● Only a limited set of data types are supported from microbit import * intensity = 0 while True: if button_a.is_pressed(): intensity += 25 if intensity > 1023: intensity = 1023 if button_b.is_pressed(): intensity -= 25 if intensity < 0: intensity = 0 display.scroll(intensity) pin0.write_analog(intensity)
  • 12. And a few others ● C++ is officially supported ○ Using either GCC or ARMCC as toolchain ○ Direct access to runtime library ● Arduino ○ C/C++ and runtime ● Pascal, Lisp, Forth and Ada are alternative languages ● Scratch 3 (block programming for kids) can be used ● Simulink (block programming for Matlab users)
  • 14. Programming Experience Toolkit (pxt) ● Provided by Microsoft ● Easy to install (for node users) ○ npm install -g pxt ● Command-line interface ● Tight integration with Visual Studio Code ○ Terminal → Run Task ● Includes a simulator (but is hard to get to work) ● Much of the runtime library is written in C++
  • 15. A new project ● Creating a new project ○ mkdir my-microbit-app && cd my-microbit-app ○ pxt target microbit - set platform ○ pxt init - create a skeleton project with VSCode integration ○ pxt npminstallnative - install basic packages ● Building your project ○ pxt build ● Run on a real device ○ pxt deploy ● Start simulator and run app ○ pxt serve ○ pxt run
  • 17. Static TypeScript ● Subset of TypeScript v2.6 ○ Most rookie code is plain JavaScript ● The usual types including strings and arrays ● any is not supported ● Generic functions cannot be values ● pxt compiles static TS to ARM assembler ○ Take a look in built/binary.hex
  • 18. A rich runtime library ● The core library includes a number of modules ○ basic - the most common functions ○ input - various input functions (buttons, gestures, …) ○ control - spawning threads and manipulation of events ○ music - play tones using a set of attached headphones ○ serial - write strings and numbers to the serial port (useful when debugging ○ console - the usual logging function ○ led - control the 5×5 display basic.forever(function () { led.toogle(3, 3) basic.pause(1000) }) let freq = 440 for (let i = 0; i < 5; i++) { freq = i * freq music.playTone(freq, 1000) }
  • 19. Input and output input.onButtonPressed(Button.A, function () { intensity += 25 if (intensity > 1023) { intensity = 1023 } }) basic.showNumber(intensity) pins.analogWritePin(AnalogPin.P0, intensity) serial.writeNumber(intensity) Register a handler to process input events Output through plain function calls
  • 20. Multitasking and events ● control.inBackground() spawns a new thread ● basic.forever() executes the same thread indefinitely ● Thread runs until it gives up the CPU - cooperative multitasking ○ Calling basic.pause() will release the CPU ● I/O events interrupts any running thread ○ So you won’t miss input.onButtonPressed() ● control.raiseEvent() emits an event ● control.onEvent() registers an event handler ● You can listen for system events ● Or create your own events Urs Steiner, https://www.flickr.com/photos/stoneysteiner/
  • 21. Multitasking and events - example let numberOfEvents = 0; control.onEvent(EventBusSource.MES_BROADCAST_GENERAL_ID, 0,function () { basic.showNumber(numberOfEvents); }); control.inBackground(function () { while (true) { numberOfEvents++; control.raiseEvent(EventBusSource.MES_BROADCAST_GENERAL_ID, 0, EventCreationMode.CreateAndFire); basic.pause(1000); } }); basic.forever(function () { serial.writeNumber(numberOfEvents); basic.pause(2000); });
  • 23. Resources ● Microbit Educational Foundation ○ https://microbit.org ● DR Ultrabit ○ https://www.dr.dk/om-dr/ultrabit ○ https://www.dr.dk/skole/ultrabit ● micro:mag ○ https://www.micromag.cc ● pxt ○ https://github.com/Microsoft/pxt ● Shops ○ https://raspberrypi.dk ○ https://elextra.dk Abington Free Library, https://www.flickr.com/photos/abingt onroslynlibraries/ https://microbit.hackster.io/rypsmith/micr o-bit-moisture-sensor-a6909c
  • 24. Time for a demo