microsoft / microsoft/pxt-microbit
Feature: more advanced `for` loops
Nobody has claimed this yet.
- 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.

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.