Arduino Terrorific Pumpkin

by jribotviayna in Circuits > Arduino

174 Views, 1 Favorites, 0 Comments

Arduino Terrorific Pumpkin

47612b49-3dc2-4f42-a0d1-1c72a88058de.jpg

Halloween has arrived to Elisava and in the UATEA subject they know it.

UATEA is a subject that teaches us the basic principles of Arduino programming and the creation of circuits using this method.

This work focuses on applying all the knowledge we have acquired during the term to a realistic project with the theme of Halloween. We have to design a project that using Arduino's coding and circuits interacts with the user.

In our case we want to do a pumpkin with leds in the eyes and we want the pumpkin rotate. It has to move and turn on the leds when the ultrasonic sensor detects a person aproaching to it.

Supplies

arduino.jpg
skull.jpg
proto.jpg
jumpers.jpg
resistence.jpg
leds.jpg
ultrasinic.jpg
servo.jpg

For this project we don't need a lot of components and all of them are assequible for the most.

We need:

  1. Arduino Uno
  2. Plastic pumpkin
  3. Protoboard
  4. 12 jumpers
  5. 2 resistences of 270 Ω
  6. 2 leds
  7. 1 ultrasonic detector
  8. 1 servo-motor

More or less about 50€

Verify the Circuit

Captura.PNG
Captura2.PNG

First of all we want to verify that the circuit works. One useful tool that we have is "tinkercad", an online platform which, among other things, allows you ton replicate circuits made in arduino and make it work. In the pictures you can see the circuit plan and the replicated circuit.

Verify the Code

captura codi 2.PNG
captura codi.PNG

For the circuit to work we need to tell the Arduino board what to do, so we need the code.

First we will explain the code and then we will show it, so that you can understand what you are telling the Arduino to do.

First of all we will define the variables that we have, in our case: Trigger, that works as the ultraonic pulse sender of the detector, Echo, that is the receiver of the pulse, LEDulls, that works as the connector of the board with the leds and finally SERVOpin, that works as the connector between the board and the servo-motor.

Next, the arduino code needs to know what each variable will be. This is declared in the void setup(). Serial.begin(9600) is used to start a "conversation" with Arduino, then we find the pinModes, which will be those connections that are made with a numeric pin, in our case we have Trigger, Echo and LEDulls. We can see that Echo has the characteristic of being INPUT, that means that this pin is coded to receive information while the other two are coded to get information. Finally we find myservo.attach(10) which is used to say that the servo is connected to pin number 10.

After void setup() we enter void loop(), which is used to tell the board what to do. First we need the ultrasonic detector to give us a distance in centimetres. To do this we declare two new variables: long t and long d.

Long t will be the echo delay time and long d the distance in centimetres. To know the distance we need to send a pulse, in our case a pulse every ten milliseconds. To scale the time to a distance in cm, we divide it by 59.

We want the program to work at less than one metre, so we need to order this condition, for this we will use an if, which will turn on the LEDs and move the servo-motor when the distance "d" is less than 100 cm.

Else is used to say that if nothing is detected below 100 cm, nothing is done


Downloads

Building the Model-Circuit

c745adf8-67bd-4b25-aa1f-ed6985582b73.jpg

Our model will be a Halloween pumpkin with some spiderweb above.

First of all we are going to make the circuit using the components.

LEDs

86b1a263-56a5-421b-81b2-49a1037ac6fa.jpg
73aa3a67-1723-4b22-a9cd-9d0ad25419dc.jpg

The second step we followed is to glue the LEDs on the pumpkin. We have to do two little holes where the LEDs will be visible.

The LEDs arrive to the eyes using two jumpers each.

Servomotor

165fa2ac-e2e3-4b36-a52e-fd5135548b13.jpg
e905f203-f5a4-45d4-b99f-17c2bf5fc412.jpg

After putting the LEDs we wanted to fix the Servo-motor. We used silicone for setting the servomotor in the pumpkin and the base

Box

692367a8-a009-40af-8bba-d5c4d7ef0b7f.jpg
8b58fa6c-a570-4728-9d75-b59a8ca678c4.jpg

Finally we make a little box for hiding the ultrasonic detector, the protoboard and the arduino

Decorate

47612b49-3dc2-4f42-a0d1-1c72a88058de.jpg
3fa9fe3d-e813-4aa5-8e4f-00e73bc4072c.jpg

Finally we wanted to make the pumpkin look spookier and more real, so we used some candies that we glued on the top, a black spider web that we put all over the system and a couple of toy spiders.

Conclusions

As a group we ended up thinking that this project helped us to assimilate all the concepts and procedures we learned during this first part of the course.