KEMBAR78
microbit Microbit programming Microbit programming | PPTX
micro:bit
FEATURES
• The micro:bit board, an ARM-based development board
• It is a very easy to use and includes a lot of peripherals
• No need for soldering or use of external hardware to get started with
• The processor is an nRF51
• It has 16 KB of RAM and 256 KB of FLASH
FEATURES
• The micro:bit has 19 GPIOs available as assignable. Up to 3 can be
assigned as PWM pins and 6 as analog inputs. The ADC of the
processor has a resolution of 10 bits
• The GPIOs also have support for I2C, SPI and Serial communication
interfaces
• The board has a Freescale MKL26Z128VFM4 microcontroller, which is
responsible for handling the USB connection between the micro:bit
board and a computer, and also for the flashing of new code.
• The micro:bit board is detected as a USB disk when connected to our
computer
Digital / Analog
FEATURES
• The micro:bit board has several peripherals on board (I2C)
• It has a Freescale MMA8653FC, a 3-axis accelerometer with a resolution of 10 bits.
• It also has an on board Freescale MAG3110 magnetometer, which allows to get
magnetic field strength measurements (I2C)
• The nRF51 processor has an integrated temperature sensor with a resolution of, 0.25°C
and an accuracy of +-4°C.
• The board has 2 two buttons for user input. There is an additional button that allows to
reset the system.
• The micro:bit board also has a 5×5 LED matrix for display purposes
• The micro:bit board has a 2.4 GHz transceiver, which allows it to support Bluetooth low
energy to establish communication with other devices
• Besides Bluetooth, the radio of the board also allows the use of the Nordic Gazell
protocol, which is a proprietary protocol that allows communication between devices
that support it. This protocol operates on the 2.4 GHz, like Bluetooth.
PROGRAMMING ENVIRONMENTS
• The micro:bit has many development environments available, some
of them designed to make it easy for beginners to get started, as
Microsoft’s MakeCode
• This editor offers the possibility of simulating the code execution very
easily. A model of the micro:bit board is located at the left side of the
code editing window and by the click of a button testing starts
• In terms of higher level languages, the micro:bit can be programmed
in Java, Python or C
MakeCode
• https://www.dfrobot.com/product-1587.html
• https://makecode.microbit.org/
• https://makecode.microbit.org/offline
• https://makecode.microbit.org/projects/
The micro:bit - a reactive system
• There are different types of computing systems, to address different kinds
of problems that arise in practice: transaction processing systems are used
by banks to handle huge numbers of financial transactions by their
customers; distributed systems make a set of networked computers appear
as one big computer (like Google’s search engine); there are also parallel
systems, such as graphic cards, which perform a huge number of primitive
operations simultaneously, using a great number of small processing cores.
• The micro:bit is a reactive system – it reacts continuously to external
events, such as a person pressing the A button of the micro:bit or shaking
the device. The reaction to an event may be to perform a computation,
update variables, and change the display. After the device reacts to an
event, it is ready to react to the next one. If this sounds like a computer
game, that’s because most computer games are reactive systems too!
The micro:bit - a reactive system
• A responsive system is able to do several things at the same time. As the micro:bit
only has one CPU it can only execute one program instruction at a time.
• The micro:bit can execute millions of instructions per second, so it is possible for
the device to alternate among instruction sequences of different programs.
• Let’s think about three sequences of instructions:
• Sequence S1: contains the instructions (let’s say several hundred thousand or so) that scroll
the number 42 across the LED screen.
• Sequence S2: contains a few instructions to check if button A is pressed.
• Sequence S3: contains a few instructions to increment a counter.
• The micro:bit interrupts the execution of sequence S1 periodically to execute the
sequence S2, which will check if button A is pressed, which looks like:
The micro:bit - a reactive system
• The result is that it takes sequence S1 a little longer to complete, due
to the interruptions to execute sequence S2, but we are checking
often enough to detect a press of button A . When S2 detects a press
of button A, then the sequence S3 can be executed before S1
resumes:
EXAMPLES
• Go to https://makecode.microbit.org/projects/
• Program examples
• Flashing Heart
• Name Tag
• Rock Paper Scissors
• Mood Radio
• Fireflies
• Go to https://www.dfrobot.com/product-1587.html
• Program Microbit Project 13:
MAQUEEN
MAQUEEN
MAQUEEN
• Supply Voltage: 3.5V-5V DC ( Three AAA batteries or 3.6V~3.7V lithium
battery )
• Infrared Grayscale Sensor(High-low level) x 2
• Buzzer x 1
• Infrared Receiver (NEC decoder) x 1
• LED Lights (High-low level control) x 2
• RGB Ambient Light (16 million colors) x 4
• SR04, SR04P Ultrasonic Interface(5V) x 1
• IIC Interface (3.3V) x 1
MAQUEEN
• Gravity Extension Interfaces (P1, P2) x 2
• N20 All-metal Gear Motor x 2
• Motor Reduction Ratio: 1:150
• Maximum Rotate Speed: 133 rpm
• Motor Drive Mode: PWM motor drive
• Bracket and Protective Cover Extension M3 Screw Hole x 6
• Programming Method: Makecode graphical programming, Mind graphical
programming (based on Scratch 3.0)
• Dimension: 81mm x 85 mm x 44mm/3.19 x 3.35 x 1.73in
• Weight: 75.55g
MAQUEEN
• Go to
https://wiki.dfrobot.com/micro:Maqueen_for_micro:bit_SKU:ROB01
48-E(ROB0148)
• Import the Makecode Graphical Library
CONTINUATION ACTIVITIES
• Download the “Terminal” at https://sites.google.com/site/terminalbpp/
• Practice the “Serial” commands
• Use the online help or visit https://makecode.microbit.org/reference/serial
• Practice the “Text” commands
• Use the online help or visit https://makecode.microbit.org/reference/text
• For the sensors “Temperature,” “Acceleration,” and “Compass,” write
programs that send the read values to the computer. Try to make the
sensor values change; consider using “pause.”
• For the Acceleration, what is the meaning of the negative values?
• For the Compass, is there any difference in the readings when the micro:bit is
horizontal, compared to when it is vertical?
CONTINUATION ACTIVITIES
• This program requires the text
terminated with CR+LF. On
terminal v1.93 you do this as
indicated in the figures below.
Check both boxes.
CONTINUATION ACTIVITIES
• For the Maqueen
• Write a program that measure distance and send to the screen
• Study the object avoidance example
• Study the line-following example, write your own version.
CONTINUATION ACTIVITIES
• This program reads the distance
from the ultrasonic sensor and
sends the value to the UART
SENDING TEXT OVER BLUETOOTH
SENDING TEXT OVER BLUETOOTH
• This functions receives “text”, a
text argument
• If the length of text exceeds the
Bluetooth capacity, an “X” is
shown, and the program gets
locked
• Else “text” is sent over Bluetooth
SENDING TEXT OVER BLUETOOTH
• This function rounds a number to two decimal places
• The result is stored in “roundResult” as text, there is not any function
to round decimal paces in MakeCode.
SENDING TEXT OVER BLUETOOTH
• This program calculates the
square root of a sequence of
numbers
• “on start” initializes Bluetooth
and the first number to obtain
the square root
• Show index is used to provide
feedback to the user

microbit Microbit programming Microbit programming

  • 1.
  • 3.
    FEATURES • The micro:bitboard, an ARM-based development board • It is a very easy to use and includes a lot of peripherals • No need for soldering or use of external hardware to get started with • The processor is an nRF51 • It has 16 KB of RAM and 256 KB of FLASH
  • 4.
    FEATURES • The micro:bithas 19 GPIOs available as assignable. Up to 3 can be assigned as PWM pins and 6 as analog inputs. The ADC of the processor has a resolution of 10 bits • The GPIOs also have support for I2C, SPI and Serial communication interfaces • The board has a Freescale MKL26Z128VFM4 microcontroller, which is responsible for handling the USB connection between the micro:bit board and a computer, and also for the flashing of new code. • The micro:bit board is detected as a USB disk when connected to our computer
  • 5.
  • 6.
    FEATURES • The micro:bitboard has several peripherals on board (I2C) • It has a Freescale MMA8653FC, a 3-axis accelerometer with a resolution of 10 bits. • It also has an on board Freescale MAG3110 magnetometer, which allows to get magnetic field strength measurements (I2C) • The nRF51 processor has an integrated temperature sensor with a resolution of, 0.25°C and an accuracy of +-4°C. • The board has 2 two buttons for user input. There is an additional button that allows to reset the system. • The micro:bit board also has a 5×5 LED matrix for display purposes • The micro:bit board has a 2.4 GHz transceiver, which allows it to support Bluetooth low energy to establish communication with other devices • Besides Bluetooth, the radio of the board also allows the use of the Nordic Gazell protocol, which is a proprietary protocol that allows communication between devices that support it. This protocol operates on the 2.4 GHz, like Bluetooth.
  • 7.
    PROGRAMMING ENVIRONMENTS • Themicro:bit has many development environments available, some of them designed to make it easy for beginners to get started, as Microsoft’s MakeCode • This editor offers the possibility of simulating the code execution very easily. A model of the micro:bit board is located at the left side of the code editing window and by the click of a button testing starts • In terms of higher level languages, the micro:bit can be programmed in Java, Python or C
  • 8.
    MakeCode • https://www.dfrobot.com/product-1587.html • https://makecode.microbit.org/ •https://makecode.microbit.org/offline • https://makecode.microbit.org/projects/
  • 10.
    The micro:bit -a reactive system • There are different types of computing systems, to address different kinds of problems that arise in practice: transaction processing systems are used by banks to handle huge numbers of financial transactions by their customers; distributed systems make a set of networked computers appear as one big computer (like Google’s search engine); there are also parallel systems, such as graphic cards, which perform a huge number of primitive operations simultaneously, using a great number of small processing cores. • The micro:bit is a reactive system – it reacts continuously to external events, such as a person pressing the A button of the micro:bit or shaking the device. The reaction to an event may be to perform a computation, update variables, and change the display. After the device reacts to an event, it is ready to react to the next one. If this sounds like a computer game, that’s because most computer games are reactive systems too!
  • 11.
    The micro:bit -a reactive system • A responsive system is able to do several things at the same time. As the micro:bit only has one CPU it can only execute one program instruction at a time. • The micro:bit can execute millions of instructions per second, so it is possible for the device to alternate among instruction sequences of different programs. • Let’s think about three sequences of instructions: • Sequence S1: contains the instructions (let’s say several hundred thousand or so) that scroll the number 42 across the LED screen. • Sequence S2: contains a few instructions to check if button A is pressed. • Sequence S3: contains a few instructions to increment a counter. • The micro:bit interrupts the execution of sequence S1 periodically to execute the sequence S2, which will check if button A is pressed, which looks like:
  • 12.
    The micro:bit -a reactive system • The result is that it takes sequence S1 a little longer to complete, due to the interruptions to execute sequence S2, but we are checking often enough to detect a press of button A . When S2 detects a press of button A, then the sequence S3 can be executed before S1 resumes:
  • 25.
    EXAMPLES • Go tohttps://makecode.microbit.org/projects/ • Program examples • Flashing Heart • Name Tag • Rock Paper Scissors • Mood Radio • Fireflies • Go to https://www.dfrobot.com/product-1587.html • Program Microbit Project 13:
  • 26.
  • 27.
  • 28.
    MAQUEEN • Supply Voltage:3.5V-5V DC ( Three AAA batteries or 3.6V~3.7V lithium battery ) • Infrared Grayscale Sensor(High-low level) x 2 • Buzzer x 1 • Infrared Receiver (NEC decoder) x 1 • LED Lights (High-low level control) x 2 • RGB Ambient Light (16 million colors) x 4 • SR04, SR04P Ultrasonic Interface(5V) x 1 • IIC Interface (3.3V) x 1
  • 29.
    MAQUEEN • Gravity ExtensionInterfaces (P1, P2) x 2 • N20 All-metal Gear Motor x 2 • Motor Reduction Ratio: 1:150 • Maximum Rotate Speed: 133 rpm • Motor Drive Mode: PWM motor drive • Bracket and Protective Cover Extension M3 Screw Hole x 6 • Programming Method: Makecode graphical programming, Mind graphical programming (based on Scratch 3.0) • Dimension: 81mm x 85 mm x 44mm/3.19 x 3.35 x 1.73in • Weight: 75.55g
  • 30.
  • 31.
    CONTINUATION ACTIVITIES • Downloadthe “Terminal” at https://sites.google.com/site/terminalbpp/ • Practice the “Serial” commands • Use the online help or visit https://makecode.microbit.org/reference/serial • Practice the “Text” commands • Use the online help or visit https://makecode.microbit.org/reference/text • For the sensors “Temperature,” “Acceleration,” and “Compass,” write programs that send the read values to the computer. Try to make the sensor values change; consider using “pause.” • For the Acceleration, what is the meaning of the negative values? • For the Compass, is there any difference in the readings when the micro:bit is horizontal, compared to when it is vertical?
  • 32.
    CONTINUATION ACTIVITIES • Thisprogram requires the text terminated with CR+LF. On terminal v1.93 you do this as indicated in the figures below. Check both boxes.
  • 33.
    CONTINUATION ACTIVITIES • Forthe Maqueen • Write a program that measure distance and send to the screen • Study the object avoidance example • Study the line-following example, write your own version.
  • 34.
    CONTINUATION ACTIVITIES • Thisprogram reads the distance from the ultrasonic sensor and sends the value to the UART
  • 35.
  • 36.
    SENDING TEXT OVERBLUETOOTH • This functions receives “text”, a text argument • If the length of text exceeds the Bluetooth capacity, an “X” is shown, and the program gets locked • Else “text” is sent over Bluetooth
  • 37.
    SENDING TEXT OVERBLUETOOTH • This function rounds a number to two decimal places • The result is stored in “roundResult” as text, there is not any function to round decimal paces in MakeCode.
  • 38.
    SENDING TEXT OVERBLUETOOTH • This program calculates the square root of a sequence of numbers • “on start” initializes Bluetooth and the first number to obtain the square root • Show index is used to provide feedback to the user