omar
Published

Playground switch

Do it yourself simple boombox made with the circuit playground express.

BeginnerProtip2 hours468
Playground switch

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Scissors, Free Fall
Scissors, Free Fall
Tape, Duct
Tape, Duct

Story

Read more

Code

Music Switch

JavaScript
This code enables us to use an external switch to turn the melody and lights on and off
pins.A1.setPull(PinPullMode.PullUp)
forever(function () {
    if (!(pins.A1.digitalRead())) {
        light.showAnimation(light.colorWipeAnimation, 2000)
    } else {
        light.clear()
    }
})
forever(function () {
    if (!(pins.A1.digitalRead())) {
        music.playMelody("C5 B A G A G A B ", 120)
    } else {
        music.stopAllSounds()
    }
})

Credits

omar
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.