Hatstall Harry Potter

by mariagomezferrer in Craft > Art

245 Views, 1 Favorites, 0 Comments

Hatstall Harry Potter

1A13F769-FE1F-4CB1-8E44-022AAC674CD0.JPG
30921E0E-BDD6-498B-AC1D-CA979C888BC0.JPG
CB37A849-D8CF-492F-B4BC-83F559C1AA3D.JPG
Captura de Pantalla 2021-11-03 a les 19.20.52.png
Captura de Pantalla 2021-11-03 a les 19.21.04.png
Captura de Pantalla 2021-11-03 a les 19.21.18.png

This project consists of implementing elements that we've learned this first part of the course, such as sensors, engines, leds, and then implementing it in a creative design within the Halloween theme.


We've chosen to make a prototype of the picker hat that appears in Harry Potter's first film, Harry Potter and the Philosophical Stone. We've managed to do this using different materials, like plastic for 3D printing, filter to get the hat effect.


And as regards the issue of the Arduino programming and code, it has been sought and modified according to our criteria and needs.


Supplies

The electronic parts we have used for our project have been as follows:

- Two servos engines, one to move the top of the hat and the other to simulate the movement of the mouth.

https://www.amazon.es/ZHITING-Walking-Helicopter-Airplane-Control/dp/B088NQTBPB/ref=sr_1_5?__mk_es_ES=ÅMÅŽÕÑ&crid=13NNEV8WMDBRR&dchild=1&keywords=servomotor+arduino&qid=1635880157&sprefix=servo%2Caps%2C386&sr=8-5

- A proximity sensor, to detect the head's proximity when putting it on and starting to start all moves.

https://www.amazon.es/azdelivery-ultrasónico-hc-SR04-telémetro-Raspberry-unidades/dp/B072N473HD/ref=sr_1_2_sspa?__mk_es_ES=ÅMÅŽÕÑ&crid=1MURKEW3VHZJB&dchild=1&keywords=sensor%2Bde%2Bproximidad%2Barduino&qid=1635880204&sprefix=sensors%2Bde%2Bproximities%2Caps%2C199&sr=8-2-spons&smid=A1X7QLRQH87QA3&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzMUg1OUdZSTdKRVUmZW5jcnlwdGVkSWQ9QTA1MTMzMDYxTU9OMklNRTNDWEJQJmVuY3J5cHRlZEFkSWQ9QTA3MzQ5NDFLNTNNQVJKNEwxWjQmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl&th=1

- A mini-protoboard.

https://www.amazon.es/Protoboard-contactos-Breadboard-prototipos-soldadura/dp/B00JGFDKBQ/ref=sr_1_10?__mk_es_ES=ÅMÅŽÕÑ&crid=XZCTGVNMRC65&dchild=1&keywords=mini+protoboard&qid=1635880229&sprefix=mini+proto%2Caps%2C337&sr=8-10

- An Arduino plate, or in our case Elego.

https://www.amazon.es/Tarjeta-Microcontrolador-ATmega328P-ATMEGA16U2-Compatible/dp/B01M7ZB2B4/ref=sr_1_2_sspa?__mk_es_ES=ÅMÅŽÕÑ&crid=24U9KLE10YTV7&dchild=1&keywords=placa+arduino&qid=1635880253&sprefix=placa+ard%2Caps%2C198&sr=8-2-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzMjM5REtWWTlFSjlXJmVuY3J5cHRlZElkPUEwNTUwNDI0SUlNQ0NRR0FPWFRGJmVuY3J5cHRlZEFkSWQ9QTA5NTE5MjYxQVdYWUNPQUtYQlFTJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==

- An SD card, where the part of the audio we want to be played will be recorded.

https://www.fnac.es/Tarjeta-SDHC-SanDisk-Ultra-16GB-Tarjeta-de-memoria-Tarjeta-SD/a1170697

- A port for the SD card.

https://www.amazon.es/ANGEEK-Player-Module-Arduino-Source/dp/B07WWTQN58/ref=sr_1_3?__mk_es_ES=ÅMÅŽÕÑ&dchild=1&keywords=port+sd+arduino&qid=1635880327&sr=8-3

- A loudspeaker, to amplify the audio stored on the SD.

https://www.amazon.es/POPESQ®-Altavoz-Miniatura-Miniature-Speaker/dp/B06Y5MXRWL/ref=sr_1_6?__mk_es_ES=ÅMÅŽÕÑ&dchild=1&keywords=altavoz+arduino&qid=1635880425&sr=8-6


The program we've used to program the code has been the Arduino program, although we've had to download an extra supplement so we can connect our plate that's not from the standard Arduino mark but from Elego.

PROTOTYPE

The physical part of our prototype has been first modeled on 3D by Solidworks software and then printed both parts (the mouth and body) with plan, a thermoplastic made from renewable resources such as wheat emmidon, tapioca roots or sugarcane. And the base used 9 mm cardboard.


To forge the hat and thus achieve the effect of the hat in question, it has been made with felt cloth, a fabric that is used to make coats and is therefore somewhat thicker and to paste it has been done so much sewing to achieve better effect and to be more resistant, so sabater glue has also been used.


CODE

Then we'll put our hat code on it.

#include <Servo.h>     //include de library for the arduino to recognize one the servo 1

//#include <Servo.h>   //include de library for the arduino to recognize one the servo 1



#include "SoftwareSerial.h"   //include de library for the arduino to to allow serial communication on other digital pins of the Arduino


#include <DFRobotDFPlayerMini.h> //include de library for the arduino to recognize de DFplayer


Servo boca;  //initialize variable for servo one

Servo punta;   //initialize variable for servo two


SoftwareSerial softwareSerial(3, 2);   //​​recognize the pins of the gps RX-2 , pin 3, and  TX-3, pin 2, of the dfPlayer



int cm=0;  // initialize variable for cm


long distancia,duracion;   //long are decimals values for the distance and the duration of the ultrasonic


int posicion1=90; //initialize variable of an enter number for posicion 1 of the servos

int posicion2=-90; //initialize variable of an enter number for posicion 2 of the servos


//We configure the pins of the sensor Trigger and Echo, Trigger will work in output mode and on the other hand Echo will work in input mode.


#define Pecho 6  //Echo pin 6

#define Ptrig 7  //Trig pin 7

 


//Create the Player object

DFRobotDFPlayerMini player;


bool plays=false; //initialize a boolean for playing the audio

long tstart=millis(); //initialize a variable just to see the timing of the ultrasonic



void setup() {

 Serial.begin (9600);   //initialize the serial port to 9600 baud

 

 

 pinMode(Pecho, INPUT); //define pin 6 as input (echo)


 pinMode(Ptrig, OUTPUT); //define pin 7 as output (triger)


 boca.attach (13);  //define pin 13 as the output to drive the servo


 punta.attach(12) ;  //define pin 13 as the output to drive the servo


  //setup DFPlayer

  softwareSerial.begin(9600); //We start the serial monitor to show the result

  if (!player.begin(softwareSerial)) {  //Use softwareSerial to communicate with mp3.

//because de dfplayer need a few seconds to start de connection with the arduino, we use this to be able to see if its going properly

    Serial.println(F("Unable to begin:")); 

    Serial.println(F("1.Please recheck the connection!"));

    Serial.println(F("2.Please insert the SD card!"));

    while(true){

      delay(0); //Code to compatible with ESP8266 watch dog, the objective of this post is to analyse some of the watchdog functions available on the Arduino IDE libraries for the ESP8266.

    }

  }


  

   player.stop(); //when the code starts, in the setup, we want the sound to be stop

 

  player.volume(30);  //Set volume to maximum (0 to 30).

  

}


void loop() {


digitalWrite (Ptrig,LOW); //we generate a clean pulse setting the trigger to LOW


  delayMicroseconds(2); 

  digitalWrite(Ptrig,HIGH); //generate the triger pulse of 10ms


  delayMicroseconds(10);

  digitalWrite(Ptrig,LOW); //we turn off the trigger


  duracion= pulseIn(Pecho, HIGH); //with this we know how long it was high (HIGH)

  distancia =(duracion/2)/29;     //calculate distance in centimeters, formula used to convert to cm



  Serial.println(distancia); //this is to see the distance that the sensor is reaching


  if (distancia <=10 && distancia >=1){  //first loop, if the distance is short

    if(plays == false){  //if the sound is off


   player.begin(softwareSerial);  //start playing the sound


    player.play(1);     //Play the first MP3 file on the SD card

    


    plays = true; //then the boolean of the sound will be true, beacause the sound is working

    }

   

  boca.write(posicion1); //if the distance is less than 10 we also want the servos to move, here we are moving the servo boca to the posicion one 90º


  punta.write(posicion1); //moving the servo punta to the posicion one 90º

  delay(1000); //is a function that makes the processor wait, so as not to saturate the board, and that it can make the first move with time, before continuing with the code


   boca.write(posicion2);  //moving the servo boca to the posicion two - 90º


    punta.write(posicion2); //moving the servo boca to the posicion two - 90º

    delay(1000); //stop for 1ms


        

  }else{ //we put this here because we want one servo to be moving all the time, so if the ditance is not less than 10

    

  if(plays == true){ //and if the sound is working we want to stop the music and make the boolean false

      player.stop();

    plays = false;

  }

    punta.write(posicion1); //and the servo punta will be moving when the plays is false and when the plays is true

  delay(1000);

   punta.write(posicion2);

    delay(1000);

  }

  }


TIKERCAD

WhatsApp Image 2021-11-03 at 19.39.07.jpeg

We will then attach the code in KiCad format, to make it more understanding.

FLOWDIAGRAM

Flow diagram is a collective term for a diagram representing a flow or set of dynamic relationships in a system and here you can see our flowdiagram.

Downloads

CONCLUSION

This work has helped us to begin to have basic notions in the world of Arduino and begin to leverage this theme, which is a less tangible theme in the other projects we have touched upon, as a new language must be used via computer and achieve a result through electronic elements, such as the two servos we have used, a loudspeaker and a sensor.


It has been very interesting and enriching, as it is the first time we have added movement to a project beyond theory and hypotheses, as the hat has had to be scaled by the weight that our servofrens can move.