Jonathon McCormack
Published

The Despacito Box

A portable (wall socket required), recyclable, and minimalist music player designed to play an infinite loop of the hook from Despacito.

BeginnerShowcase (no instructions)269
The Despacito Box

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
The brains behind the Despacito Box
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
Used for the volume adjustment
×1
Toggle Switch, DPDT
Toggle Switch, DPDT
Turns Despacito on or off
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
Powers the Despacito Box
×1
Alligator Clips
Alligator Clips
Used to connect all the bits inside the Despacito Box, the height of quality construction
×1

Software apps and online services

MakeCode
Microsoft MakeCode
Used to program the Despacito Box and create the lovely monotone melody it plays

Story

Read more

Schematics

Despacito Box Schematic

Code

Despacito Box Code

JavaScript
This is the entire mess that is the code behind the Despacito Box. One loop controls the volume and lights through the potentiometer, and the other contains all of the notes that had to be put into their own IF statements with an additional IF that turns the sound off in order to be stopped at any point during the series of notes. The section that graphs the potentiometer and controls the lights was modified based on the Adafruit Make it Change guide, the rest was made custom.
let value = 0
pins.A2.setPull(PinPullMode.PullUp)
pins.A3.setPull(PinPullMode.PullUp)
music.setVolume(0)
music.setTempo(89)
forever(function () {
    value = pins.A1.analogRead()
    light.graph(value, 900)
    console.logValue("value", value)
    music.setVolume(value)
})
forever(function () {
    if (!(pins.A3.digitalRead())) {
        music.stopAllSounds()
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Whole))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(554, music.beat(BeatFraction.Whole))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(370, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(392, music.beat(BeatFraction.Whole))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(392, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(392, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(392, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(392, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(494, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(554, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Whole))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(440, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(587, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(659, music.beat(BeatFraction.Quarter))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(659, music.beat(BeatFraction.Half))
    }
    if (!(pins.A2.digitalRead())) {
        music.playTone(554, music.beat(BeatFraction.Whole))
    }
})

Credits

Jonathon McCormack

Jonathon McCormack

4 projects • 2 followers
Student and cosplayer/propmaker

Comments