Declan Ford
Published © GPL3+

PartyBox

A portable lightweight box that plays music and a light show when it is turned on.

BeginnerShowcase (no instructions)2 hours205
PartyBox

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Toggle Switch, SPDT
Toggle Switch, SPDT
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Scissors, Free Fall
Scissors, Free Fall

Story

Read more

Code

PartyBox Code

JavaScript
Code for the PartyBox, created in Microsoft MakeCode.
pins.A2.setPull(PinPullMode.PullUp)
pins.A1.setPull(PinPullMode.PullUp)
music.setTempo(138)
music.setVolume(255)
forever(function () {
    if (pins.A2.digitalRead()) {
        light.showAnimation(light.rainbowAnimation, 1000)
    } else {
        light.clear()
    }
})
forever(function () {
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Whole))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(349, music.beat(BeatFraction.Whole))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(392, music.beat(BeatFraction.Quarter))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(262, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Whole))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(440, music.beat(BeatFraction.Whole))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(466, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(440, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(349, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(440, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(440, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(262, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(262, music.beat(BeatFraction.Whole))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(330, music.beat(BeatFraction.Half))
    }
    if (pins.A2.digitalRead()) {
        music.playTone(294, music.beat(BeatFraction.Breve))
    }
    if (pins.A1.digitalRead()) {
        music.stopAllSounds()
        light.setAll(0x000000)
    }
})

Credits

Declan Ford

Declan Ford

4 projects • 0 followers

Comments