Skip to content

Commit

Permalink
Merge branch 'master' into fix-reaction-game
Browse files Browse the repository at this point in the history
  • Loading branch information
ganicke authored Aug 29, 2024
2 parents fe8eaec + 11693f8 commit cfbdc23
Show file tree
Hide file tree
Showing 157 changed files with 2,423 additions and 1,278 deletions.
2 changes: 1 addition & 1 deletion docs/courses.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Tutorials, lessons, and mini-courses about programming and computing.
}, {
"name": "Networking with the micro:bit",
"description": "A series of activities to teach the basics of computer networks.",
"url": "https://microbit.nominetresearch.uk/",
"url": "https://www.digitaltechnologieshub.edu.au/search/networking-with-the-micro-bit/",
"imageUrl": "/static/courses/networking-book.png"
}, {
"name": "SparkFun Videos",
Expand Down
10 changes: 5 additions & 5 deletions docs/courses/csintro/iteration/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

In computer programming, iteration is the repetition of a sequence of code. A loop is a form of iteration. A loop repeats code until a certain condition is met.

## Questions for the students:
* Do you use shampoo to wash your hair? _Most will say ‘Yes’_.
* Have you ever read the instructions on a bottle of shampoo? _Most will say ‘No’_.
## Questions to think about:
* Do you use shampoo to wash your hair?
* Have you ever read the instructions on a bottle of shampoo?

Most of us have never read the instructions on a bottle of shampoo, because we already know how to use shampoo.

Expand All @@ -15,7 +15,7 @@ Example:
3. Scrub shampoo into hair
4. Rinse shampoo out of hair

If you did read the instructions on a bottle of shampoo, you may read similar instructions as the ones you just wrote with one added step at the end. That step is ‘Repeat.’
If you did read the instructions on a bottle of shampoo, you may read similar instructions as the ones you just wrote with one added step at the end: ‘Lather. Rinse. Repeat.’
How does this one extra step affect the algorithm?

![Shampoo flowchart](/static/courses/csintro/iteration/shampoo-flowchart.png)
Expand All @@ -29,7 +29,7 @@ DBwebsolutions.com
What other common activities involve repetitive actions? _Examples: Singing (choruses repeat), dancing, school cheers, walking and running, exercise routines..._

## Optional
Share with your students the history of ‘Lather, Rinse, Repeat.’
Read the history of ‘Lather, Rinse, Repeat.’ below.

Lather, Rinse, Repeat: Hygiene Tip or Marketing Ploy
By Lauren Goldstein
Expand Down
56 changes: 34 additions & 22 deletions docs/extensions/extension-gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,55 @@ Many extensions are available to work with interface kits, add-on hardware, or o
```codecard
[{
"name": "Display",
"url": "/extensions#display",
"url": "/extensions/extension-gallery#display",
"cardType": "link"
}, {
"name": "Electronics",
"url": "/extensions#electronics",
"url": "/extensions/extension-gallery#electronics",
"cardType": "link"
}, {
"name": "Gaming",
"url": "/extensions#gaming",
"url": "/extensions/extension-gallery#gaming",
"cardType": "link"
}, {
"name": "Individual sensors",
"url": "/extensions#individual-sensors",
"url": "/extensions/extension-gallery#individual-sensors",
"cardType": "link"
}, {
"name": "IoT",
"url": "/extensions#iot",
"url": "/extensions/extension-gallery#iot",
"cardType": "link"
}, {
"name": "Kits",
"url": "/extensions#kits",
"url": "/extensions/extension-gallery#kits",
"cardType": "link"
}, {
"name": "LEDs and lights",
"url": "/extensions#leds-and-lights",
"url": "/extensions/extension-gallery#leds-and-lights",
"cardType": "link"
}, {
"name": "Machine learning",
"url": "/extensions#machine-learning",
"url": "/extensions/extension-gallery#machine-learning",
"cardType": "link"
}, {
"name": "Robotics",
"url": "/extensions#robotics",
"url": "/extensions/extension-gallery#robotics",
"cardType": "link"
}, {
"name": "Sensor boards",
"url": "/extensions#sensor-boards",
"url": "/extensions/extension-gallery#sensor-boards",
"cardType": "link"
}, {
"name": "Sound",
"url": "/extensions#sound",
"url": "/extensions/extension-gallery#sound",
"cardType": "link"
}, {
"name": "Wearables",
"url": "/extensions#wearables",
"url": "/extensions/extension-gallery#wearables",
"cardType": "link"
}, {
"name": "Utilities",
"url": "/extensions#utilities",
"url": "/extensions/extension-gallery#utilities",
"cardType": "link"
}]
```
Expand All @@ -70,6 +70,10 @@ Many extensions are available to work with interface kits, add-on hardware, or o

```codecard
[{
"name": "Pythom1234 OLED Display SSD1306 128x64",
"url": "/pkg/Pythom1234/pxt-oled",
"cardType": "package"
}, {
"name": "Joy-IT RB-TFT1.8",
"url": "/pkg/joy-it/pxt-RB-TFT1.8",
"cardType": "package"
Expand Down Expand Up @@ -355,7 +359,7 @@ Many extensions are available to work with interface kits, add-on hardware, or o
"cardType": "package"
}, {
"name": "WiFi:Bit",
"url":"/pkg/e-radionicacom/pxt-wifi",
"url":"/pkg/SolderedElectronics/pxt-wifi",
"cardType": "package"
}, {
"name": "ESP8266 and ThingSpeak",
Expand Down Expand Up @@ -517,6 +521,10 @@ Many extensions are available to work with interface kits, add-on hardware, or o

```codecard
[{
"name": "Lectrify Brick:Bit",
"url":"/pkg/softsmyth/lectrify-b4k",
"cardType": "package"
}, {
"name": "KittenBot TabbyBot",
"url":"/pkg/KittenBot/pxt-tabbyrobot",
"cardType": "package"
Expand Down Expand Up @@ -804,6 +812,18 @@ Many extensions are available to work with interface kits, add-on hardware, or o
"name": "TinkerTanker Stepper Motor",
"url":"/pkg/Tinkertanker/pxt-stepper-motor",
"cardType": "package"
}, {
"name": "ALS Robot Keyboard",
"url":"/pkg/alsrobot-microbit-makecode-packages/ALSRobotKeyboard",
"cardType": "package"
}, {
"name": "Elecfreaks NeZha",
"url": "/pkg/elecfreaks/pxt-nezha",
"cardType": "package"
}, {
"name": "Elecfreaks NeZha V2",
"url": "/pkg/elecfreaks/pxt-nezha2",
"cardType": "package"
}]
```

Expand Down Expand Up @@ -1071,13 +1091,5 @@ Many extensions are available to work with interface kits, add-on hardware, or o
"name": "Proportional Font",
"url":"/pkg/lwchkg/pxt-proportional-font",
"cardType": "package"
}, {
"name": "ALS Robot Keyboard",
"url":"/pkg/alsrobot-microbit-makecode-packages/ALSRobotKeyboard",
"cardType": "package"
}, {
"name": "Elecfreaks NeZha",
"url": "/pkg/elecfreaks/pxt-nezha",
"cardType": "package"
}]
```
2 changes: 1 addition & 1 deletion docs/projects/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
* [micro:bit Data and Sustainability](https://mrmorrison.co.uk/microbit/datasustainability/)
* [First Steps](https://microbit.org/get-started/first-steps/introduction/)
* [Make it: code it](https://microbit.org/projects/make-it-code-it/)
* [Networking with the micro:bit](https://microbit.nominetresearch.uk/)
* [Networking with the micro:bit](https://www.digitaltechnologieshub.edu.au/search/networking-with-the-micro-bit/)
* [SparkFun Videos](https://youtu.be/kaNtg1HGXbY?list=PLBcrWxTa5CS0mWJrytvii8aG5KUqMXvSk)
* [Logic Lab](/courses/logic-lab)
* [CodeJoy Remote Robotics](https://www.codejoyeducation.com)
Expand Down
2 changes: 1 addition & 1 deletion docs/projects/analog-pin-tester.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Press ``A`` to scroll the value on the screen.

```blocks
let reading = 0
basic.forever(() => {
basic.forever(function () {
reading = pins.analogReadPin(AnalogPin.P0)
led.plotBarGraph(
reading,
Expand Down
50 changes: 25 additions & 25 deletions docs/projects/banana-keyboard/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ Have you ever tried making beat box sounds? Let's try making a beatbox with code
Start by adding a variable to store a musical note. Rename the variable to `sound`. Set the value of the variable to the note block `Middle A` from the **Music** drawer.

```blocks
let sound = music.noteFrequency(Note.A);
let sound = music.noteFrequency(Note.A)
```

We want to play music when the fruit connected to a pin pressed. So, we register an event handler that executes whenever pin **1** is pressed. Pin **1** is, of course, connected to the banana. Add a ``||input:on pin pressed||`` block from the **Input** drawer.

```blocks
let sound = music.noteFrequency(Note.A);
input.onPinPressed(TouchPin.P1, () => {
let sound = music.noteFrequency(Note.A)
input.onPinPressed(TouchPin.P1, function () {
})
```

Now, let's create some notes to play when the banana is pressed. Click on the **Loops** drawer then insert a ``||loops:repeat||`` loop into the ``||input:on pin pressed||`` block. Click on the **Variables** drawer and pull out a ``||variables:change item by||`` block and put it into the loop. Rename the variable to `sound`. Change the value from `1` to `25`. This will increase the variable `sound` from the note frequency of block `Middle A` to `Middle A` plus 25 and so on. Put a ``||variables:set to||`` block for `sound` right after the loop. Set it to `Middle A` in order to reset the sound after a banana press.

```blocks
let sound = music.noteFrequency(Note.A);
let sound = music.noteFrequency(Note.A)
input.onPinPressed(TouchPin.P1, () => {
input.onPinPressed(TouchPin.P1, function () {
for (let i = 0; i < 4; i++) {
sound += 25;
sound += 25
}
sound = music.noteFrequency(Note.A);
});
sound = music.noteFrequency(Note.A)
})
```

Finally, insert a ``||music:play tone||`` above the ``||variables:change by||``. Pull out the ``sound`` variable block and drop it in the note slot of ``||music:play tone||``. Change the beat fraction from `1` to `1/4`.

```blocks
let sound = music.noteFrequency(Note.A);
let sound = music.noteFrequency(Note.A)
input.onPinPressed(TouchPin.P1, () => {
input.onPinPressed(TouchPin.P1, function () {
for (let i = 0; i < 4; i++) {
music.playTone(sound, music.beat(BeatFraction.Quarter));
sound += 25;
music.playTone(sound, music.beat(BeatFraction.Quarter))
sound += 25
}
sound = music.noteFrequency(Note.A);
});
sound = music.noteFrequency(Note.A)
})
```

Click `|Download|` and try a banana press. Did you hear 4 notes play?
Expand All @@ -55,23 +55,23 @@ Go back to **[Make](/projects/banana-keyboard/make)** and repeat steps 7 and 8 w
Duplicate the ``||input:on pin pressed||`` event handler to make a second one. For the new ``||input:on pin pressed||``, change the pin name to **P2**. In the pin **P2** event, let's have the the frequency in the variable `sound` decrease by 25 instead of having it increase. Change the `25` in the ``||variables:change by||`` block to `-25`. OK, your code now looks like this:

```blocks
let sound = music.noteFrequency(Note.A);
let sound = music.noteFrequency(Note.A)
input.onPinPressed(TouchPin.P1, () => {
input.onPinPressed(TouchPin.P1, function () {
for (let i = 0; i < 4; i++) {
music.playTone(sound, music.beat(BeatFraction.Quarter));
sound += 25;
music.playTone(sound, music.beat(BeatFraction.Quarter))
sound += 25
}
sound = music.noteFrequency(Note.A);
});
sound = music.noteFrequency(Note.A)
})
input.onPinPressed(TouchPin.P2, () => {
input.onPinPressed(TouchPin.P2, function () {
for (let i = 0; i < 4; i++) {
music.playTone(sound, music.beat(BeatFraction.Quarter));
sound += -25;
music.playTone(sound, music.beat(BeatFraction.Quarter))
sound += -25
}
sound = music.noteFrequency(Note.A);
});
sound = music.noteFrequency(Note.A)
})
```

Click `|Download|` again and play both bananas. It's a fruit jam session!
2 changes: 1 addition & 1 deletion docs/projects/banana-keyboard/make.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Your banana keyboard is ready!

Connect your @boardname@ to your computer using your USB cable and run this script:
```blocks
input.onPinPressed(TouchPin.P1, () => {
input.onPinPressed(TouchPin.P1, function () {
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
});
```
Expand Down
24 changes: 12 additions & 12 deletions docs/projects/crashy-bird.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Before creating the code for the game actions, let's first add some controls so
```blocks
let bird: game.LedSprite = null
input.onButtonPressed(Button.A, () => {
input.onButtonPressed(Button.A, function () {
bird.change(LedSpriteProperty.Y, -1)
})
input.onButtonPressed(Button.B, () => {
input.onButtonPressed(Button.B, function () {
bird.change(LedSpriteProperty.Y, 1)
})
```
Expand Down Expand Up @@ -79,11 +79,11 @@ for (let index = 0; index <= 4; index++) {
}
}
input.onButtonPressed(Button.A, () => {
input.onButtonPressed(Button.A, function () {
bird.change(LedSpriteProperty.Y, -1)
})
input.onButtonPressed(Button.B, () => {
input.onButtonPressed(Button.B, function () {
bird.change(LedSpriteProperty.Y, 1)
})
```
Expand All @@ -97,7 +97,7 @@ Right click on the ``||value||`` block and rename it to ``||obstacle||``
```blocks
let obstacles: game.LedSprite[] = []
basic.forever(() => {
basic.forever(function () {
for (let obstacle of obstacles) {
obstacle.change(LedSpriteProperty.X, -1)
}
Expand All @@ -114,7 +114,7 @@ Make obstacles disappear after reaching leftmost corner. Iterate over all obstac
```blocks
let obstacles: game.LedSprite[] = []
basic.forever(() => {
basic.forever(function () {
while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
obstacles.removeAt(0).delete()
}
Expand All @@ -134,7 +134,7 @@ At the moment, our code generates just one vertical obstacle. We need to put obs
let emptyObstacleY = 0
let obstacles: game.LedSprite[] = []
basic.forever(() => {
basic.forever(function () {
while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
obstacles.removeAt(0).delete()
}
Expand All @@ -159,7 +159,7 @@ let ticks = 0
let emptyObstacleY = 0
let obstacles: game.LedSprite[] = []
basic.forever(() => {
basic.forever(function () {
while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
obstacles.removeAt(0).delete()
}
Expand Down Expand Up @@ -190,7 +190,7 @@ let ticks = 0
let emptyObstacleY = 0
let obstacles: game.LedSprite[] = []
basic.forever(() => {
basic.forever(function () {
while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
obstacles.removeAt(0).delete()
}
Expand Down Expand Up @@ -226,17 +226,17 @@ let emptyObstacleY = 0
let obstacles: game.LedSprite[] = []
let index = 0
let bird: game.LedSprite = null
input.onButtonPressed(Button.A, () => {
input.onButtonPressed(Button.A, function () {
bird.change(LedSpriteProperty.Y, -1)
})
input.onButtonPressed(Button.B, () => {
input.onButtonPressed(Button.B, function () {
bird.change(LedSpriteProperty.Y, 1)
})
index = 0
obstacles = []
bird = game.createSprite(0, 2)
bird.set(LedSpriteProperty.Blink, 300)
basic.forever(() => {
basic.forever(function () {
while (obstacles.length > 0 && obstacles[0].get(LedSpriteProperty.X) == 0) {
obstacles.removeAt(0).delete()
}
Expand Down
Loading

0 comments on commit cfbdc23

Please sign in to comment.