Broadcasting 2
Lesson (25 mins):
Classroom Code / Project: Send Radio Message
Equipment: (1 for each Trainee)
Micro:bit
computer
USB cord
Skills
Explore possibilities
self-experimentation
Keywords
documentation
combining
map
Let’s look at Documentation!!!
Let’s say you want to combine some of the ideas you’ve learned from past lessons together but you don’t know what you need.
Makecode has a documentation resource that can help point you in the direction you need to experiment.
You can look at this information two ways, on almost every block, you can right-click and select help to open up the entry in the same window or you can look through the Makecode documentation site or makecode.microbit.org/blocks
While you’re here:
Take a look at the pages under the “Things to do” heading on the documentation site to see some of the tutorials offered here. In the future, this site and others like it can be a source of inspiration for other Micro:bit projects to do!
Example Idea
Say you want to create a wearable that changes brightness based on which direction you’re facing?
You need to use the compass, and LEDs, Set the Brightness of LEDs, and a way to get them to work together.
The hint here is that the compass can give us a number that is bigger than the number that brightness can take. The second hint is that a block under math can help us here.
Right-click on the blocks you think might work and look at the help passage to find the blocks you need.
Set your LED string
Under the (...) section of Neopixel Find the “Set Brightness Block”
Brightness is set between 0-255
Under inputs, find “Compass heading”
This value can be between 0-360
This will partially work but because the ranges don’t match there can be some unexpected behavior.
Under Math, drag over the map block and put the compass heading block inside the first number field. In the next two put 0 and 360 for the range of the compass. In the last two put 0 and 255 for the range of the brightness.
This can be useful for a lot of inputs that can deal with very different numbers. Once you find the range of values for a sensor (which is usually in the documentation) you can then map that value to something like sound or light.
There’s also another block in there with a comment explaining a different way of combining LEDs, the compass, and the map function.