Animal Crossing Mailbox

by TheFourthSword in Circuits > Arduino

274 Views, 1 Favorites, 0 Comments

Animal Crossing Mailbox

WhatsApp Image 2020-06-16 at 11.46.42 (1).jpeg
WhatsApp Image 2020-06-16 at 11.46.42.jpeg

Hey there! I'm going to teach you how to make your own animal crossing mailbox!

Supplies

  1. Wood and tools to put together a simple box for your mail
  2. An arduino uno
  3. A breadboard
  4. Wires
  5. A piezo buzzer
  6. A force sensitive resistor
  7. A powerbank
  8. A servo motor
  9. A little flag of your own design
  10. Springs

Setting Up Your Arduino

WhatsApp Image 2020-06-16 at 11.46.45.jpeg
WhatsApp Image 2020-06-16 at 11.46.44 (1).jpeg
WhatsApp Image 2020-06-16 at 11.46.44.jpeg
  1. Connect the piezo buzzer to the 12 and GND pin, where you want the + to connect to the 12
  2. Connect the orange wire of your servo motor to the 9 pin
  3. Connect the red servo wire to the + row
  4. Connect the black servo wire to the - row
  5. Connect a white wire to the + row and to Vin
  6. Connect a green wire to the - row and to GND
  7. Connect a yellow and white wire on opposite sides of the light side of a 10K resistor
  8. Connect the yellow wire to A0
  9. Connect the white wire to your Force sensitive resistor
  10. Connect a red wire to the 5V
  11. Connect the other end of the red wire to your Force sensitive resistor

Code!

#include //include servo from library const int buzzerPin = 12; //attach buzzer to pin 12 const int servoPin = 9; //attach servo to pin 9 int fsrAnalogPin = 0; int fsrReading; Servo servo1; //define servo const int delayBite = 300; //calculate delay String song[][2] = { //code for the song. the first one is the note, the second one is the tempo {"C", "1"}, {"a", "1"}, {"-", "6"} }; String songStress[][2] = { //the second song {"C", "1"}, {"a", "1"}, {"-", "0"} }; int tempo = 250; //tempo in general, calculates the tempo it goes in together with the tempo defined in the song void playNote(char note, int duration) { //defining of the notes and their height char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'E' }; int tones[] = { 1915, 1700, 1519, 1432, 1275, 900, 1014, 600, 750 }; for (int i = 0; i < sizeof(names); i++) { //if the variable i is lower than the size of the song, play the next note if (names[i] == note) { playTone(tones[i], duration); } } } void playTone(int tone, int duration) { //plays the music for (long i = 0; i < duration * 1000L; i += tone * 2) { digitalWrite(buzzerPin, HIGH); delayMicroseconds(tone); digitalWrite(buzzerPin, LOW); delayMicroseconds(tone); } } void setup() { pinMode(buzzerPin, OUTPUT); servo1.attach (servoPin); Serial.begin(9600); servo1.write(0); } void loop() { fsrReading = analogRead(fsrAnalogPin); Serial.println(fsrReading); int songSize = sizeof(song) / sizeof(song)[0]; //define the song int songStressSize = sizeof(songStress) / sizeof(songStress)[0]; if (fsrReading > 5 and fsrReading < 300) { //define the measurements for the first pressure size servo1.write(90); for (int a = 0; a < songSize; a++) { if (song[a][0].charAt(0) == '-') { //plays the first song if the first pressure measurement is met delay(song[a][1].toInt()*tempo); } else { playNote(song[a][0].charAt(0), song[a][1].toInt()*tempo); } } } else if (fsrReading > 299) { //if there's more pressure than the first measurement, the servo will move more and the second song will start playing for (int a = 0; a < songStressSize; a++) { if (songStress[a][0].charAt(0) == '-') { delay(songStress[a][1].toInt()*tempo); } else { playNote(songStress[a][0].charAt(0), songStress[a][1].toInt()*tempo); } } servo1.write(90); delay(delayBite); servo1.write(50); } else { //if neither of these requirements are met, drop the servo to the 0 position and stop beeping servo1.write(0); } }

Putting the Mailbox Together!

WhatsApp Image 2020-06-16 at 13.29.17.jpeg

Now that you've set up your wires, you'll need to put together your mailbox! This is as simple as making a box with a slot and a lid, and a hole in the side.

After you've put it together and decorated it to your hearts content, you can put all your wires in.

Start with gluing the servo motor to the side of the box, so the little arm sticks out of the side, to attach your flag to.

Then, make sure you have a cover to hide your wires, and attach the Force sensitive resistor on top of it.

Then you'll want to make a little platform with springs, as otherwise the Force sensitive resistor won't work.

Use five springs, one for on the sensor, four for on the sides, and then put some cardboard on top.

After you've attached your platform to your sensor, and you got your mail ready, you're good to go! Enjoy your cool new mailbox.