HACKED HALLOWEEN BOX

by joan6a2000 in Circuits > Arduino

313 Views, 0 Favorites, 0 Comments

HACKED HALLOWEEN BOX

WhatsApp Image 2021-11-04 at 21.45.21 (4).jpeg

This build is part of a midcourse project for the Engineering in Industrial Design program at the ELISAVA university of engineering and design. Our assignment was to create something Halloween themed. We decided to approach this in a different perspective from our classmates. We were not looking for a horror product, instead we wanted a useful and stylish product that gave the sensation of confusion to the user.

Our initial thoughts were the problems that can appear by doing a trick or treat in a pandemic period, to help on that aspect we brainstormed and thought about making a candy dispenser so you don’t have to open and be around kids but still give them their candies.

The way we want to give kids their candy is by putting their hand in a dark hole that will sense them and give them candy. To complete this task we believe a box would be the best shape and killer artificial intelligence the best aesthetic. We were inspired by hall from the space odyssey film.

With this instructable we'll add all the plans to build it out of thin wood and also the 3d models to print it at home!

Making the Circuit

WhatsApp Image 2021-11-04 at 23.20.06.jpeg

We have to create and mount a circuit using a protoboard and a ARDUINO UNO. in this circuit we'll use a 180º microservo, a 28BYJ-48 stepper motor, buzzer, 100K ohm resistance, 4 red LEDs, HC-SR04 distance sensor, Protoboard, Arduino UNO and cables. We got everything out from a little online arduino kit. LINK: https://www.uctronics.com/maker-kits/arduino-kits/uctronics-advanced-starter-kit-for-arduino-with-instruction-booklet-uno-r3-uno-r3-proto-shied-v3-relay-breadboard-power-supply-sg90-9g-servo-remote-controller-and-ir-receiver.html

Be careful and connect everything in the circuit right, try to use our same color of cable if you can. The motor over the microservo in the picture is the stepper if it wasn't clear enough.

Coding

WhatsApp Image 2021-11-04 at 23.58.26.jpeg

We have to code our circuit luckily for you I've already done that task and I'll give it to you under this phrase (it comes with comments so you can understand everything); we've taken the luxury of adding the doom melody but you can download many from the internet:

the link in github is: https://github.com/joan6a2000/JOAN.git

In case this doesn't work for you.

//start of the buzzer melody we have to declare all the notes
#define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 37 #define NOTE_DS1 39 #define NOTE_E1 41 #define NOTE_F1 44 #define NOTE_FS1 46 #define NOTE_G1 49 #define NOTE_GS1 52 #define NOTE_A1 55 #define NOTE_AS1 58 #define NOTE_B1 62 #define NOTE_C2 65 #define NOTE_CS2 69 #define NOTE_D2 73 #define NOTE_DS2 78 #define NOTE_E2 82 #define NOTE_F2 87 #define NOTE_FS2 93 #define NOTE_G2 98 #define NOTE_GS2 104 #define NOTE_A2 110 #define NOTE_AS2 117 #define NOTE_B2 123 #define NOTE_C3 131 #define NOTE_CS3 139 #define NOTE_D3 147 #define NOTE_DS3 156 #define NOTE_E3 165 #define NOTE_F3 175 #define NOTE_FS3 185 #define NOTE_G3 196 #define NOTE_GS3 208 #define NOTE_A3 220 #define NOTE_AS3 233 #define NOTE_B3 247 #define NOTE_C4 262 #define NOTE_CS4 277 #define NOTE_D4 294 #define NOTE_DS4 311 #define NOTE_E4 330 #define NOTE_F4 349 #define NOTE_FS4 370 #define NOTE_G4 392 #define NOTE_GS4 415 #define NOTE_A4 440 #define NOTE_AS4 466 #define NOTE_B4 494 #define NOTE_C5 523 #define NOTE_CS5 554 #define NOTE_D5 587 #define NOTE_DS5 622 #define NOTE_E5 659 #define NOTE_F5 698 #define NOTE_FS5 740 #define NOTE_G5 784 #define NOTE_GS5 831 #define NOTE_A5 880 #define NOTE_AS5 932 #define NOTE_B5 988 #define NOTE_C6 1047 #define NOTE_CS6 1109 #define NOTE_D6 1175 #define NOTE_DS6 1245 #define NOTE_E6 1319 #define NOTE_F6 1397 #define NOTE_FS6 1480 #define NOTE_G6 1568 #define NOTE_GS6 1661 #define NOTE_A6 1760 #define NOTE_AS6 1865 #define NOTE_B6 1976 #define NOTE_C7 2093 #define NOTE_CS7 2217 #define NOTE_D7 2349 #define NOTE_DS7 2489 #define NOTE_E7 2637 #define NOTE_F7 2794 #define NOTE_FS7 2960 #define NOTE_G7 3136 #define NOTE_GS7 3322 #define NOTE_A7 3520 #define NOTE_AS7 3729 #define NOTE_B7 3951 #define NOTE_C8 4186 #define NOTE_CS8 4435 #define NOTE_D8 4699 #define NOTE_DS8 4978 #define REST 0

// this tempo variable is handy for making the song go slower or faster int tempo = 325;

// the number 2 is the pin we'll use in the arduino int buzzer = 2;

// This code uses PROGMEM to fit the melody to flash as it was to0 long to fit

const int melody[] PROGMEM = {

// the melody is from At Doom's Gate // all this variables and numbers are the notes of the moledy followed by the duration. // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on // the negative numbers are used to represent dotted notes,

NOTE_E2, 8, NOTE_E2, 8, NOTE_E3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_D3, 8, NOTE_E2, 8, NOTE_E2, 8, //61 NOTE_C3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_AS2, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_B2, 8, NOTE_C3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_E3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_D3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_E4, -16, NOTE_B3, -16, NOTE_G3, -16, NOTE_G4, -16, NOTE_E4, -16, NOTE_G3, -16, NOTE_B3, -16, NOTE_D4, -16, NOTE_E4, -16, NOTE_G4, -16, NOTE_E4, -16, NOTE_G3, -16,

NOTE_E2, 8, NOTE_E2, 8, NOTE_E3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_D3, 8, NOTE_E2, 8, NOTE_E2, 8, //73 NOTE_C3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_AS2, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_B2, 8, NOTE_C3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_E3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_D3, 8, NOTE_E2, 8, NOTE_E2, 8, NOTE_B3, -16, NOTE_G3, -16, NOTE_E3, -16, NOTE_B2, -16, NOTE_E3, -16, NOTE_G3, -16, NOTE_C4, -16, NOTE_B3, -16, NOTE_G3, -16, NOTE_B3, -16, NOTE_G3, -16, NOTE_E3, -16, }; //We shortened the melody by cutting most of the notes

// sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) // there are two values per note (pitch and duration), so for each note there are four bytes int notes = sizeof(melody) / sizeof(melody[0]) / 2;

// this calculates the duration of a whole note in ms int wholenote = (60000 * 4) / tempo;

int divider = 0, noteDuration = 0; //end of the melody code

#include

//here we inculde a library for our distance sensor #include

#include

//a library for the servo

Servo myservo; // we create a servo object to control our servo

UltraSonicDistanceSensor distanceSensor(7, 6); //we initialize the sensor saying the trigger pin is connected to the 7th arduino port and the echopin is on the 6th

int val; // declaring the variable that will contain the distance measured by the sensor int gir = 180; //we proceed to initialize the variable of our 180º servo this vaiable will determine its position int i = 0; this variable counts how many times the distance sensor is triggered so we can know later

//stepper #define STEPPER_PIN_1 10 #define STEPPER_PIN_2 11 #define STEPPER_PIN_3 12 #define STEPPER_PIN_4 13 int step_number = 0; bool Onestep = false;

void setup() { pinMode(6, INPUT); pinMode(7, OUTPUT); Serial.begin(9600); //monitor to work myservo.attach(8); // attaches the servo on pin 8 to the servo object myservo.write(180); //we move the servo to the 180º initial position delay(200); //this delay is for the servo tohave time to arrive to its position //stepper pinMode(STEPPER_PIN_1, OUTPUT); //attaches the stepperpin1 to the 10th pin and declares it as output pinMode(STEPPER_PIN_2, OUTPUT); pinMode(STEPPER_PIN_3, OUTPUT); pinMode(STEPPER_PIN_4, OUTPUT);

//buzzersetup

} void loop() {

val = distanceSensor.measureDistanceCm(); //this function will make our sensor size the distance in cm Serial.println(val); //this will helpu us keep track of the sensor and whatit is percieving if (val < 12 && val >= 1) { //if the distance the sensor percieves is between 11 and 1 then... if (i == 3) { //if it is the 4th time the sensor is triggered then... Serial.println("hola"); //just for us to know wich way the code is going Serial.println(gir); //to keep track of the position f the servo //stepper begins rotating for (int a = 0; a < 10240; a++) { //variable a is the steps our stepper takes it is in fullstep and has 2048 steps per revolution so it'll do 5 revolutions before it stops OneStep(true); // this bool will decide wich way the stepper goes: true clockwise and false counterclockwise delay(2); //minimum delay between steps in ours is 2 miliseconds } for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { //here starts the loop for the buzzer it is inside the if and it plays after the servo is in its position

// calculates the duration of each note divider = pgm_read_word_near(melody + thisNote + 1); if (divider > 0) { // regular note, just proceed noteDuration = (wholenote) / divider; } else if (divider < 0) { // dotted notes are represented with negative durations noteDuration = (wholenote) / abs(divider); noteDuration *= 1.5; // increases the duration in half for dotted notes }

// we only play the note for 90% of the time the remaining 10% is a pause tone(buzzer, pgm_read_word_near(melody + thisNote), noteDuration * 0.9);

// Wait for the specief duration before playing the next note. delay(noteDuration);

noTone(buzzer); //buzzerend

} delay(500); digitalWrite(7, HIGH); //The 4 LEDs will light up delay(1000); gir = gir + 45; //We augment the gir variable myservo.write(0); //servo goes to 0 to drop all of the candy left in the treadmill for (int a = 0; a < 10240; a++) { OneStep(false); delay(2); //minimum delay between steps in ours is 2 miliseconds } delay(1000);

//stepperends

i = 0; //variable i goes back to 0 so we start the cycle again gir = 180; myservo.write(180);//servo goes back to the beggining at 180º delay(8000);// we wait that much so the sensor doesn't get triggered another time by a kid trying to grab its candy digitalWrite(7, LOW); //led go off

}

else { //the three first times the program willl do this part wich is just dropping some candy by rotating the servo that drives the treadmill Serial.println("adeu"); //for us to control what the program is doing gir = gir - 30; myservo.write(gir);

i = i + 1; //we add 1 to i so qhen it goes to 4 the if will be true and the other part of the code runs delay (5000); } } }

void OneStep(bool dir) { //variable dir declares the direction of rotation if (dir) { switch (step_number) {// this code uses fullsteping instead of microsteping because the loss in torque is not significant case 0: digitalWrite(STEPPER_PIN_1, HIGH); //as the stepper works with 4 coils we turn on one each time so it moves really fast and fluent digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, LOW); break; case 1: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, HIGH);// next coil turns on digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, LOW); break; case 2: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, HIGH); digitalWrite(STEPPER_PIN_4, LOW); break; case 3: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, HIGH); break; } } else { switch (step_number) { case 0: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, HIGH);// same thing just the other direction break; case 1: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, HIGH); digitalWrite(STEPPER_PIN_4, LOW); break; case 2: digitalWrite(STEPPER_PIN_1, LOW); digitalWrite(STEPPER_PIN_2, HIGH); digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, LOW); break; case 3: digitalWrite(STEPPER_PIN_1, HIGH); digitalWrite(STEPPER_PIN_2, LOW); digitalWrite(STEPPER_PIN_3, LOW); digitalWrite(STEPPER_PIN_4, LOW);

} } step_number++; if (step_number > 3) { step_number = 0; //this controls that the code before is repeated on and on till copleting the desired steps } }

Design Your Box

WhatsApp Image 2021-11-05 at 01.03.07.jpeg
WhatsApp Image 2021-11-05 at 01.00.14.jpeg

You can use our design but we must admit it hasn't the spookiest shapes ever. As we said before it is thought to be more as a confusion and shock than not fear so if you prefer any other design feel free to do so and you can use our code too.

If You Have a 3D Printer This Step Is for You!

Screenshot 2021-11-04 221040.png
Screenshot 2021-11-04 221226.png
Screenshot 2021-11-04 223051 (1).png

You can see our 3D model in the pictures above and we hope you love it. If you do we are happy to share our STL files with everything measured to fit perfectly so you just have to worry about printing and enjoying the spooky halloween box.

Step 4: Construction Materials and Tools

WhatsApp Image 2021-11-04 at 21.45.24.jpeg
WhatsApp Image 2021-11-05 at 01.00.12.jpeg

This task we'll be a bit time consuming if you're doing it alone and you are not using a 3d printer or laser cutter but it is possible anyways. We can prove it by doing it ourselves.

First of all the materials for the 3D printer are easy evereything can be done in PLA. For the manual and more crafty build we'll use:

MATERIALS:

-MDF board 60 x 30 x 4 mm (x4units)

-MDF board 60 x 30 x 15 mm

-20 x 7 mm aluminium axes

-19x7x6 mm bearings (x5units)

-Screws 15 x 4 (x20units)

-Circular Magnets 5x2mm (x2units)

-Black wrap 200x30 mm minimum

-White wrap 100x30 mm minimum

-Board of red plexiglass 10x10mm

-Staples -Rubber band 20 x 10 x 5 mm

TOOLS:

-Drill of 4mm

-Drill of 5mm

-Drill of 19mm -Star screwdriver

-Silicone gun -Glue for metal and wood

-Sandpapers of different grains

-Little pulleys (x2units)

-Stapler

-Woodsaw

-Metalsaw

Step 5: Construction Procedure

WhatsApp Image 2021-11-04 at 21.45.21 (2).jpeg
WhatsApp Image 2021-11-04 at 21.45.21.jpeg
WhatsApp Image 2021-11-04 at 21.45.23.jpeg
WhatsApp Image 2021-11-04 at 21.45.21 (3).jpeg
WhatsApp Image 2021-11-05 at 01.03.21.jpeg

1.We can't use 3D printers so this is our method. To do the box we used cheap MDF board as its uniform and easy to work with. Make a box and structure parts

We used cheap MDF board as its uniform and easy to work with Using a thicker piece of MDF cut out the parts that will hold the candy feeder, servo motor, conveyor belt and make the holes that need the sides of the box. Alternatively you can 3D print this design we have also provided but not tested yet.

2. Make the rollers for the conveyor belt

For the rollers we used standard cylindrical wooden profile and fed an aluminium axle through the ends. These ends then are stuck into ball bearings glued into the thicker pieces of mdf. Providing enough grip for the conveyor belt is key, we used hot glue that we left to dry to provide some more friction, but a thin piece of rubber could work even better.Remember to leave the end of the leftmost roller without an axle protruding as this end will be connected to the stepper motor, that will drive the conveyor belt

3.Make the conveyor belt

You can make a makeshift conveyor belt with a thin piece of rubber which can be stapled or sown together, otherwise you can use a piece of grippy paper or fabric. Also we added some silicon to the rollers so they can have more grip.

4. Making the head and pulley system

The head of the robot hiding in the box can easily be made out of a standard cylindrical wooden profile. We drilled through the center to create a cavity for the LEDs to shine in and then cut the top of the cylinder of, split it in two and glued a piece of transparent coloured that will transmit the light from the LEDs and act as a creepy eye.The pulley was made using two standard metal pulley wheels and hooks connected to the stand that holds the head when it is resting and not protruding from the box.

It is important to create tension with the pulley on both sides of the head so that it is not jammed into the hole under an angle. the stand can be simple and made out of a piece of scrap wood, we drilled a hole on the base that will house a baring and a roller, that will be spool the string lifting up the head with the help of a servo motor

5. Build the structure This is the moment when you assemble all the parts of the box: the sides, bottom and top but without the front so you can still work inside the box. The pulley and conveyor belt structure should be installed by this point.

6. Sensors and arduino

Mount the distance sensor somewhere near the hole so it is able to perceive the change in distance and all the other electronics connected to the arduino like the servo motors, the steppers and breadboard.

7. Finish the build

Now it's time to finish the build and check everything fits correctly and works.

8. Disassemble and wrap. If it works, disassemble the walls and then wrap all the sides with vinyl wrap, or whatever looks good to you :).

9. Time to enjoy!