Casper

by mayfer in Circuits > Arduino

864 Views, 7 Favorites, 0 Comments

Casper

image00015.jpeg
CASPER

Casper is a ghost who can move his arms and light up his eyes when someone approaches him. His aim is to scare people who pass in front of him.

In this project, we have put into practice the concepts learnt in the classes of academic uses in specific terminology in English 1, a third year subject in the degree of industrial design engineering at the Elisava University.

To create the phantom, we used a programming code, as well as the creation of a prototype and a mechanism capable of carrying out the movement.

The programming is connected to the physical mechanism by means of an electrical circuit that contains LEDs, sensors and a servomotor that carries out the movement.

The materials used are shown below, as well as the steps that have been followed to make the final prototype. A TinkerCad simulation of how the electronic components are connected is also shown.

Downloads

Flow Diagram and Program

Captura de pantalla 2022-11-03 180106.png

The first step was to program the code for our project.

To do the programming, we applied the concepts seen in class. We programmed a sensor so that when it detects an object nearby, the ghost's red LED eyes light up and its arms move to make the white fabric undulate. We wanted to scare people who approached him.

Likewise, we used Tinkercad, an electrical circuit simulator, to test the programming code we were making and to be able to detect its functionality, as well as the mistakes we were making. On the other hand, by assembling the circuit with the components on this platform, we were able to see if we were doing it right. In this way, we will save time in the assembly of the electrical part.


CODE:

#include <Servo.h>


Servo myservo;

int pos = 0;

const int Trigger = 13;  //Pin digital 2 para el Trigger del sensor

const int Echo = 12;     //Pin digital 3 para el Echo del sensor

int ledPinD = 8;

int ledPinE = 2;


void setup() {

  myservo.attach(6);

  Serial.begin(9600);          //iniciailzamos la comunicaciĆ³n

  pinMode(Trigger, OUTPUT);    //pin como salida

  pinMode(Echo, INPUT);        //pin como entrada

  digitalWrite(Trigger, LOW);  //Inicializamos el pin con 0

  pinMode(ledPinD, OUTPUT);

  pinMode(ledPinE, OUTPUT);

  myservo.write(0);  

}


void loop() {

  long t;  //timepo que demora en llegar el eco

  long d;  //distancia en centimetros


  digitalWrite(Trigger, HIGH);

  delayMicroseconds(10);  //Enviamos un pulso de 10us

  digitalWrite(Trigger, LOW);


  t = pulseIn(Echo, HIGH);  //obtenemos el ancho del pulso

  d = t / 1000;               //escalamos el tiempo a una distancia en cm


  Serial.print("Distancia: ");

  Serial.print(d);  //Enviamos serialmente el valor de la distancia

  Serial.print("cm");

  Serial.println();

  delay(100);  //Hacemos una pausa de 100ms


  if (d < 50 && d != -1) {

    digitalWrite(ledPinD, HIGH);

    digitalWrite(ledPinE, HIGH);

    for (int i = 0; i < 3; i++) {

      myservo.write(0);

      delay(1000);

      myservo.write(40);

      delay(1000);

    }

    myservo.write(0);

    digitalWrite(ledPinD, LOW);

    digitalWrite(ledPinE, LOW);

  }

}

Downloads

Electrical Part

tinkercad.png

The second step was to assemble the electrical part. For this we used the Arduino connected to a breadboard. The breadboard allows us to create and test electronic circuits, without having to print the circuit.

So, we connected two LED lights to the breadboard and the Arduino, each with a series resistor to limit the current flowing and prevent them from burning out. These are connected to the boards with jumper connectors, as they needed to be connected at a great distance from the breadboard.

The servo motor and the sensor are also connected to the boards. The sensor is the HC-SR04 5V ultrasonic distance sensor.

The Arduino powers the breadboard, so we can connect all our components to the power. It is also in charge of storing the program and executing it, so the components will be activated when we want them to be.

As it is an electro circuit it needs to release the energy that enters, for this the breadboard is connected to the ground of the Arduino, to avoid burning the circuit when not being able to release the current.

Functional Prototype

prototype1.png

Once we had the program code and the electrical part clear, we made a first functional prototype, in order to better develop the internal mechanism that would make the arms stand up. We used foam board, as it is an easy material to work with and at the same time resistant.

We decided to design a 5-bar articulated mechanism in order to have more freedom of movement. It moves thanks to an articulated quadrilateral connected to the motor.

Final Prototype

1.jpg
2.jpg
3.jpg

With the idea clear, we decided to make the final prototype. This was on a larger scale, so we had to try to reduce weight and friction so that the servo motor would be able to move it. In order to do this, we carried out the following steps:

1_ Cut the wood for the base and the main structure.

2_ Make the hole to insert the motor.

3_ Making the articulated mechanism. For the bars we chose cardboard to help us reduce weight, we joined them with pins and washers to be able to generate the movement.

4_ Once the mechanism and the main structure are joined, with a half sphere of Styrofoam, we simulate the head of the ghost. We made two small holes to later insert the eyes with LEDs.

5_ The next step was to join the main structure to the base. We put them together using angle brackets.

6_ Finally, cut out the white fabric to cover the inner skeleton and give it the appearance of a ghost.

Conclusion

This project has allowed us to put into practice all the content we have worked on in class. Thus, we have used all the concepts and knowledge in a real case.

We have broadened our knowledge of programming and of the different electrical components that exist.

At the beginning of the work we set ourselves an objective, to be able to make, in a larger size, the first functional prototype. As we have observed, this objective has been achieved, since thanks to the mechanism designed, the motor has been able to support a greater weight.

To conclude, we really enjoyed doing this type of project, because we learnt, through programming, how to transfer information from the digital world to the real world.