$$ \newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor} \newcommand{\ceil}[1]{\left\lceil{#1}\right\rceil} \renewcommand{\mod}{\,\mathrm{mod}\,} \renewcommand{\div}{\,\mathrm{div}\,} \newcommand{\metar}{\,\mathrm{m}} \newcommand{\cm}{\,\mathrm{cm}} \newcommand{\dm}{\,\mathrm{dm}} \newcommand{\litar}{\,\mathrm{l}} \newcommand{\km}{\,\mathrm{km}} \newcommand{\s}{\,\mathrm{s}} \newcommand{\h}{\,\mathrm{h}} \newcommand{\minut}{\,\mathrm{min}} \newcommand{\kmh}{\,\mathrm{\frac{km}{h}}} \newcommand{\ms}{\,\mathrm{\frac{m}{s}}} \newcommand{\mss}{\,\mathrm{\frac{m}{s^2}}} \newcommand{\mmin}{\,\mathrm{\frac{m}{min}}} \newcommand{\smin}{\,\mathrm{\frac{s}{min}}} $$

Prijavi problem


Obeleži sve kategorije koje odgovaraju problemu

Još detalja - opišite nam problem


Uspešno ste prijavili problem!
Status problema i sve dodatne informacije možete pratiti klikom na link.
Nažalost nismo trenutno u mogućnosti da obradimo vaš zahtev.
Molimo vas da pokušate kasnije.

Project Task - the Bracelet

In one elementary school, at the end of the second grade, students present to their parents what they learned during the second grade. During the event, several students should be wearing bracelets, which should display flowers when students wearing them move their hands.

A bracelet, which displays flowers can be made by using a Micro:bit device. The appearance of flowers will be simulated by LEDs turning on and off every time the user moves his/her hand.

_images/Narukvica1.png

For making the bracelet, you will need:

  • 1 Micro:bit

  • Fabric or decorative paper

  • Scissors

  • Adhesive tape/Thread

It is necessary to program the Micro:bit to show a flower on its display (5x5 LED grid) every time the user shakes his/her hand.

Step 1

Go to https://makecode.microbit.org/.

We want to create a program, which will allow the Micro:bit display to show a flower every time a movement is made, more precisely, we want to register any type of movement with the Micro:bit device by using its accelerometer. The display puts out the desired image (by turning on the LEDs) only when a movement is detected.

For solving this task, we will use one of the conditional blocks (branching blocks) with the condition being that a movement has been made. Which line (branch) of the code will be used depends on whether the condition has been fulfilled or not. If a movement has been registered, the Micro:bit device will display a flower, and if not, the LEDs will stay turned off.

Step 2

Start a new project and drag the block if..then from the category Logic into the block forever, located in the category Basic.

The blocks placed inside the forever block will run until the Micro:bit is turned off.

Drag the block uslov1 (located in the category Input) into the input field for the condition uslov.

From the drop-down list of the block uslov1:

_images/s81.png

choose the shake option. This option registers movements.

_images/s101.png

Based on the setup of the task, a flower will be displayed on the Micro:bit when a movement has been registered (i.e. in our case when the condition has been fulfilled). It is necessary to drag the blocks for displaying the flower (which turn on specific LEDs) from the Basic category into the branch (condition fulfilled, or branch YES):

_images/s12.png

We will use three show leds blocks for displaying the flower. These blocks will be used for displaying the desired image of a flower. The look of the program when a movement has been made:

_images/s131.png

Based on the setup of the task, there is also a condition which says that if a movement has not been registered, nothing should be displayed on the Micro:bit. To achieve this, we need to add a branch, which will run certain blocks when the condition has not been fulfilled (in our case, when there is no movement). We can add this branch by clicking on the sign plus. To this branch we will add the block clear, which is used to clear the Micro:bit display.

The final look of the code for the bracelet:

_images/s161.png

Simulation:

_images/s171.png

Step 3

Download the .hex file to your computer by clicking on the button dugme1dugme2. The Micro:bit will be ready to start working once you have dragged the file onto it.

When you finish programming the Micro:bit, place it into the already made bracelet case and start using it.

Bracelet:

_images/Narukvica2.png