More one pager project edits (#597)

This commit is contained in:
Galen Nickel 2017-12-06 20:23:17 -08:00 committed by Peli de Halleux
parent 7ef65715d7
commit f7a2a24ed8
6 changed files with 59 additions and 61 deletions

View File

@ -1,15 +1,15 @@
# compass
![](/static/mb/projects/a5-compass.png)
Display the direction that the @boardname@ is facing using the compass
# Compass
## ~avatar avatar
Welcome! This guided tutorial will show you how to program a script that displays the direction the @boardname@ is pointing. Let's get started!
Welcome! This guided tutorial will show you how to program a script that displays which direction the @boardname@ is pointing. Let's get started!
## ~
![](/static/mb/projects/a5-compass.png)
Display the direction that the @boardname@ is facing using the compass.
## Step 1
Create a loop that will continuously update the reading of the compass.
@ -33,7 +33,7 @@ basic.forever(() => {
## Step 3
If `degrees` is less than `45` or greater than `315`,
then the compass heading is mostly pointing toward North. Display `N` on the @boardname@.
then the compass heading is mostly pointing toward **North**. Display `N` on the @boardname@.
```blocks
basic.forever(() => {
@ -46,8 +46,7 @@ basic.forever(() => {
## Step 4
If `degrees` is less than 135, the @boardname@ is mostly pointing East. Display `E` on the @boardname@.
If `degrees` is less than `135`, the @boardname@ is mostly pointing **East**. Display `E` on the @boardname@.
```blocks
basic.forever(() => {
@ -63,8 +62,7 @@ basic.forever(() => {
## Step 5
If `degrees` is less than 225, the @boardname@ is mostly pointing South. Display `S` on the @boardname@.
If `degrees` is less than `225`, the @boardname@ is mostly pointing **South**. Display `S` on the @boardname@.
```blocks
basic.forever(() => {
@ -83,7 +81,7 @@ basic.forever(() => {
## Step 6
If none of these conditions returned true, then the @boardname@ must be pointing West. Display `W` on the @boardname@.
If none of these conditions returned true, then the @boardname@ must be pointing **West**. Display `W` on the @boardname@.
```blocks
basic.forever(() => {

View File

@ -9,16 +9,16 @@ Turn your @boardname@ into fireflies.
https://youtu.be/ZGvtnE1Wy6U
## How do Fireflies synchronise?
## How do Fireflies synchronize?
Go to http://ncase.me/fireflies/ and read about the fireflies synchronization phenomenon.
## Code
## Code the firefly
We want to create virtual fireflies using multiple @boardname@ (each @boardname@ acts as a firefly).
Let's review some of the key points of the article:
We want to create virtual fireflies using multiple @boardname@s (each @boardname@ acts as a firefly).
Let's review some of the key points from the article:
## "Each firefly has its own individual internal clock"
### "Each firefly has its own individual internal clock..."
A clock in this case is like a counter, so we will start by adding a ``clock`` variable to our program.
@ -27,10 +27,10 @@ A clock in this case is like a counter, so we will start by adding a ``clock`` v
let clock = 1
```
## "and every time the clock “strikes twelve”, it flashes."
### "...and every time the clock 'strikes twelve', it flashes."
We can use a [forever](/reference/basic/forever) loop to repeat code that increments the clock.
When the clock reaches "noon" (let's pick `8`), we turn on the screen briefly (by using the game score animation)
We can use a ``||basic:forever||`` loop to repeat code that increments the clock.
When the clock reaches "noon" (let's pick `8` as noon), we turn on the screen briefly (by using the game score animation)
```block
// the clock ticker
@ -53,12 +53,11 @@ basic.forever(() => {
})
```
## Step 1: when you see a nearby firefly flash, nudge your clock a little bit forward.
### When you see a nearby firefly flash, nudge your clock a little bit forward
The @boardname@ can send radio messages to neighbor @boardname@.
We can use these messages to simulate the "flashes" of light.
The @boardname@ can send radio messages to a neighbor @boardname@. We can use these messages to simulate the "flashes" of light.
* When a firefly flashes, it also sends a number over radio using [radio send number](/reference/radio/send-number).
When a firefly flashes, it also sends a number over radio using ``||radio:radio send number||``:
```block
// the clock ticker
@ -83,7 +82,7 @@ basic.forever(() => {
})
```
* When a firefly receives a radio packet, it increments its clock by one.
When a firefly receives a radio packet, it increments its clock by one:
```block
// the clock ticker
@ -94,13 +93,13 @@ radio.onDataPacketReceived(() => {
})
```
## Putting all together
## Put it all together
https://youtu.be/XzZeB4yYnEw
Download this program on as many @boardname@ as you can find and try it out in a dark room!
Download this program on as many @boardname@s as you can find and try it out in the dark!
(We've added a [radio set group](/reference/radio/set-group) block to specify which group the firefly will communicate on).
**Note:** We've added a ``||radio:radio set group||`` block to specify which group the firefly will communicate on.
```blocks
// the clock ticker

View File

@ -40,8 +40,7 @@ basic.showLeds(`
## Step 4
Move the blocks inside the ``||basic:forever||``
to repeat the animation.
Move the blocks inside the ``||basic:forever||`` to repeat the animation.
```block
basic.forever(() => {
@ -63,7 +62,7 @@ basic.forever(() => {
## Step 5
Click ``|Download|`` to transfer your code in your @boardname@!
Click ``|Download|`` to transfer your code in your @boardname@ and watch the hearts flash!
## Step 6

View File

@ -1,5 +1,6 @@
# love meter
# Love meter
Make a love meter, how sweet! The @boardname@ is feeling the love, then sometimes not so much!
## Step 1

View File

@ -1,17 +1,18 @@
# magic button trick
# Magic button trick
## ~avatar avatar
Build a magic trick that uses the @boardname@'s compass to detect a nearby magnet!
## ~
This is a simple magic trick you can perform to amaze your friends, where by moving the sticky labels on your @boardname@'s **A** and **B** button you appear to make the buttons really switch over. To see the trick performed watch the video below.
This is a simple magic trick you can perform to amaze your friends! When you move the sticky labels on your @boardname@'s **A** and **B** button, you appear to make the buttons really switch over. To see the trick performed watch the video below.
https://youtu.be/-9KvmPopov8
## How the trick works
Unfortunately, the only magic here is in the code. This trick uses a magnet, hidden in your hand, to tell the @boardname@ to swap over the buttons so that when the magnet is near the microbit the **A** button starts working like the **B** button and the **B** button starts working like the **A** button.
The **magic** here is really in the code. This trick uses a magnet, hidden in your hand, to tell the @boardname@ to swap over the buttons. When the magnet is near the @boardname@, the **A** button starts working like the **B** button and the **B** button starts working like the **A** button. Tricky!
## What you need
@ -19,10 +20,9 @@ The only things you need for this trick are your @boardname@ and any magnet that
![](/static/mb/projects/magic-button-trick/magnets.jpg "Magnets")
## Step 1: Getting the buttons to display **A** and **B**
## Step 1: getting the buttons to display **A** and **B**
Before we code the trick itself, we need to get the buttons working as you would expect them to so that pressing button **A** displays 'A' and pressing button **B** displays 'B':
Before we code the trick itself, we need to get the buttons working as you would expect them to such that pressing button **A** displays 'A' and pressing button **B** displays 'B':
```blocks
input.onButtonPressed(Button.A, () => {
@ -33,29 +33,29 @@ input.onButtonPressed(Button.B, () => {
})
```
## Step 2: measuring magnetic force
## Step 2: Measuring magnetic force
We will use the @boardname@'s compass to detect the magnet. Compass's tell us what direction we are pointing by detecting the Earth's magnetic field but they can also detect any other magnet nearby. We will use that to check if our magnet is next to the @boardname@ by using the [magnetic force](/reference/input/magnetic-force) block found in the input menu's 'more' section. As we only want to measure the strength we change the drop down to select 'strength':
We will use the @boardname@'s compass to detect the magnet. A compass tells us which direction we are pointing to by detecting the Earth's magnetic field, but it can also detect any other magnet nearby. We will use that to check if our magnet is next to the @boardname@ by using the ``||input:magnetic force||`` block found in the **Input** menu's **... More** section. Since we only want to measure the strength we change the drop down to select `strength`:
```block
input.magneticForce(Dimension.Strength)
let force = input.magneticForce(Dimension.Strength)
```
## Step 3: checking if the magnetic is nearby
## Step 3: Checking if the magnetic is nearby
Now we can measure the magnetic force near the microbit, we can check if the value we measure is so big that it means there must be a strong magnet nearby.
Now we can measure the magnetic force near the @boardname@. We can check if the value we measure is so big that it means there must be a strong magnet nearby.
If you have ever played with magnets you know they have two ends, often called a north and south 'pole'. Depending on which end of the magnet is pointing at the microbit the magnetic force measurement will either be a negative number like -100 or a positive number like 100. We just want to know if the strength is at least 100 we don't care if its negative or positive so we also use the 'absolute value of' block from the maths menu to tell our code to ignore the negative sign and just treat -100 as if its 100.
If you've ever played with magnets you know they have two ends, often called a North and South 'pole'. Depending on which end of the magnet is pointing at the @boardname@, the magnetic force measurement will either be a negative number (like, -100) or a positive number (like, 100). We just want to know if the strength is at least 100. We don't care if its negative or positive so we also use the ``||math:absolute of||`` block from the **Math** menu to tell our code to ignore the negative sign and just treat `-100` as if its `100`.
So in the code below we will check if the absolute value of our magnetic field strength reading is more than 100 and save the result of that check in a new variable called 'isSwitched':
So, in the code below, we will check if the absolute value of our magnetic field strength reading is more than `100` and save the result of that check in a new variable called ``isSwitched``:
```blocks
let force = Math.abs(input.magneticForce(Dimension.Strength));
let isSwitched = force > 100
```
## Step 4: running our 'magnet nearby' check all the time
## Step 4: Running our 'magnet nearby' check all the time
At the moment our code to detect the magnet being nearby will only run once so we need to put it into a [forever](/reference/basic/forever) block so that it keeps getting run again and again checking for the magnet to come near to the @boardname@. We should also make sure 'isSwitched' is false when our program starts.
At the moment, our code to detect a magnet being nearby will only run once. We need to put it into a ``||basic:forever||`` loop so that it keeps running again and again, checking for the magnet to come near to the @boardname@. We should also make sure ``isSwitched`` is set to `false` when our program starts.
```blocks
let force = 0;
@ -66,9 +66,9 @@ basic.forever(() => {
})
```
## Step 5: swapping the buttons when we know the magnet is nearby
## Step 5: Swapping the buttons when we know the magnet is nearby
Now we can check the value of our variable 'isSwitched' whenever we want and we will know that the magnet is nearby if it's value is 'true'. Let's use that to change how the buttons work and complete the code for our trick. We will add an 'if, else' block to each button's code and check if we should swap over what each button displays because 'isSwitched' is equal to true:
Now we can check the value of our variable ``isSwitched`` whenever we want and we will know that the magnet is nearby if it's value is `true`. Let's use that to change how the buttons work and complete the code for our trick. We will add an ``||logic:if then else||`` block to each button's code and check if we should swap over what's displayed for each button if ``isSwitched`` is equal to `true`:
```blocks
let force = 0;
@ -92,12 +92,12 @@ input.onButtonPressed(Button.B, () => {
basic.showString("B")
}
})
```
## step 5: practice your performance
Now you just need to program your own @boardname@ and practice the trick a few times before performing to friends. Try asking your friends to click the buttons after you have switched the labels and the trick won't work for them as they don't have a hidden magnet in their hand.
## Step 6: Practice your technique
Now you just need to program your own @boardname@ and practice the trick a few times before performing for your friends. Try asking your friends to click the buttons after you have switched the labels and the trick won't work for them because they don't have a hidden magnet in their hand!
## about the authors
This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can chekout their [@boardname@ tutorials chanel on youtube](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) for more projects.
## About the authors
This project was contributed by Brian and Jasmine Norman, aka [@MicroMonstersUK](https://twitter.com/MicroMonstersUK). You can checkout their [MicroMonsters](https://www.youtube.com/channel/UCK2DviDexh_Er2QYZerZyZQ) tutorials channel on YouTube for more projects.

View File

@ -1,12 +1,12 @@
# messenger
# Messenger
![](/static/mb/projects/a9-radio.png)
Use the radio to create an app that sends "YO" messages.
Use the radio in an app that sends "YO" messages.
## Step 1
Use [on button pressed](/reference/input/on-button-pressed) to send the number "0" over radio.
Use ``||input:on button pressed||`` to send the number `0` over radio.
```blocks
input.onButtonPressed(Button.A, () => {
@ -16,7 +16,7 @@ input.onButtonPressed(Button.A, () => {
## Step 2
Use [radio on data packet received](/reference/radio/on-data-packet-received) display "YO" when the number ``0`` is received
Use ``||radio:on data packet received||`` display "YO" when the number ``0`` is received
by radio.
```blocks
@ -29,11 +29,11 @@ radio.onDataPacketReceived(({ receivedNumber }) => {
})
```
Download the program and **upload the same .hex file to 2 devices!**
Download the program to one @boardname@ and then to another. Press button **A** on one and see if the other gets a message.
## Step 3
Use [on button pressed](/reference/input/on-button-pressed) to send the number "1" over radio.
Use ``||input:on button pressed||`` to send the number `1` over radio.
```blocks
input.onButtonPressed(Button.B, () => {
@ -43,7 +43,7 @@ input.onButtonPressed(Button.B, () => {
## Step 4
Add blocks in [radio on data packet received](/reference/radio/on-data-packet-received) to display "BYE" when the number ``1`` is received
Add blocks in ``||radio:on data packet received||`` to display "BYE" when the number ``1`` is received
by radio.
```blocks
@ -59,6 +59,7 @@ radio.onDataPacketReceived(({ receivedNumber }) => {
})
```
Download the program to the @boardname@s again and try your messenger!
```package
radio