Well, I looked everywhere to find the music box. I suppose not literally everywhere, but I found myself searching obscure websites. From Chinese wholesalers to upscale artisanal music box makers. I even emailed a few people on Etsy, but was forced to select from a limited selection.
So I'm building it myself ヽ(´ ー`)ノ
There are still a few things to work out, most notably:
After finding the sheet music online and marking the notes, the process went like this:
Normally, I would create a whole repo for the code used. But for now, this is all there is.
int REED_PIN = D0;
int MOTOR_PIN = D3;
int LED_PIN = D7;
int MOTOR_SPEED = 255;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(REED_PIN, INPUT_PULLUP);
pinMode(MOTOR_PIN, OUTPUT);
}
void loop() {
bool lidIsOpen = digitalRead(REED_PIN) == LOW;
if (lidIsOpen) {
digitalWrite(LED_PIN, HIGH);
startMotor();
} else {
digitalWrite(LED_PIN, LOW);
stopMotor();
}
}
void startMotor() {
analogWrite(MOTOR_PIN, MOTOR_SPEED);
}
void stopMotor() {
analogWrite(MOTOR_PIN, 0);
}
Here's the actual song for reference: Pan's Labyrinth Lullaby
Authored by Anthony Fox on 2018-02-09