josh rain
Published © GPL3+

Sound Box

Adjustable sound and random notes, with on/off switch.

BeginnerShowcase (no instructions)1 hour539
Sound Box

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

wires

wiring

Code

sound box code

JavaScript
let tone = 0
music.setVolume(153)
forever(function () {
    tone = pins.A3.analogRead()
    music.playTone(tone, music.beat(BeatFraction.Sixteenth))
    light.setAll(light.rgb(tone * Math.randomRange(1, 25), tone * Math.randomRange(1, 25), tone * Math.randomRange(1, 25)))
})
forever(function () {
    if (pins.A4.digitalRead()) {
        music.stopAllSounds()
    } else {
        music.playTone(tone * Math.randomRange(1, 50), music.beat(BeatFraction.Sixteenth))
    }
})

Credits

josh rain
2 projects • 0 followers

Comments