microsoft / microsoft/pxt-microbit

Feature: more advanced `for` loops

Open
#3,837 12 comments 2 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

apis extension
Dominant language
TypeScript
Stars
804
Forks
721
Avg merge
2d 9h
Merged PRs (30d)
2

Description

Is your feature request related to a problem? Please describe.
Working with frequencies and sweeping frequencies is a really fun way to make sound with the micro:bit V2.

The 'for loop' is an ideal construct for this, as it lets you make some good sounds with very little code.

Describe the solution you'd like
I'd like a block that lets the user set the start and increment value for the for loop index variable.

I think this could make sense as a new block

for <index> from <start> to <end> with step <step> translating to:

for (let index = start; index <= end; index+=step) {
}

Describe alternatives you've considered

The user can always use maths in the loop to do this, but for many students this greatly increases the complexity of the code required for simple sound effects.

We've done whole activities around playing with a 'frequencySweep' function which could be entirely replaced with a for loop

stinging together a range of these with different start, end, step and delays would make cool sounds.
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.