Thanos

Thanos © GPL3+

Thanos is a fictional character, a supervillain. It appears in the comic books published by Marvel. Controlled by Arduino in this project.

  • 222 views
  • 9 comments
  • 21 respects

Components and supplies

Apps and online services

About this project

Thanos is a fictional character, a supervillain. It appears in the comic books published by Marvel. Controlled by Arduino in this project.

Our project uses the Arduino Uno board to read the Ultrasonic sensor. If someone is identified at 50 cm is he activa relay board (connected in the play of the sound box) and the servo of the mouth.

When the Relay activates the play of the sound box, it plays a song (Thanos' voices) and the frequency of loudspeaker activates the servo in the mouth.

  • We use a servo to move the mouth.
  • We use a servo to move the head.
  • We use an Ultrasonic Sensor to detect people.
  • We used 2 green LEDs to light up while he speaks.

Code

Thanos_final.inoArduino
#include <Servo.h>
Servo boca,servo;

#include <Ultrasonic.h>
Ultrasonic ultra(3,2);//Trig-Echo

#define play 9  
#define led 8
#define pulso A1

int x=0;
int pos= 0;
int distancia;
int valoratual;

int pisca;

void setup() {

servo.attach(10,0,180);
boca.attach(11);

 Serial.begin(9600);
 pinMode(led,OUTPUT);
 pinMode(play,OUTPUT);
 pinMode(pulso,INPUT);



}

void loop() {
  distancia=ultra.Ranging(CM);
  
  for(int i = pos; i <=180; i++)
  {
    valoratual=analogRead(pulso);

    distancia=ultra.Ranging(CM);
    Serial.print("Distancia de ");
    Serial.print(distancia);
    Serial.print(" em ");
    Serial.print(i);
    Serial.println(" graus.");
    servo.write(i);
    pos = i;
    delay(20);
    if(distancia<48)
    {
      Serial.println("Vi alguem, vou falar!");
      Play();
      servo.write(i);    
      break;         
    }
  }
  for (int j = pos; j>=0;j--)
  {
    distancia=ultra.Ranging(CM);

    Serial.print("Distancia de ");
    Serial.print(distancia);
    Serial.print(" em ");
    Serial.print(j);
    Serial.println(" graus.");
    
    servo.write(j);
    pos = j;
    delay(20);
    if(distancia<48)
    {
      Play();
      servo.write(j);  
      break;        
    }
  } 
}

void Play(){
  distancia=ultra.Ranging(CM);
  if(distancia<48)
  {
  Serial.println("Dando o play.");
  digitalWrite(play,LOW);
  delay(200);
  digitalWrite(play,HIGH);
  
  }
  valoratual=analogRead(pulso);
  distancia=ultra.Ranging(CM);
  while (distancia<48)
  {
    valoratual=analogRead(pulso);
    Serial.print("Falando..");
    Serial.print(valoratual);

    valoratual=map(valoratual,640,735,70,0);
    boca.write(valoratual);
    if(valoratual<50)
    {
      digitalWrite(led,HIGH);
    }
    else digitalWrite(led,LOW);
    delay(50);
    distancia=ultra.Ranging(CM);
    Serial.print("Distancia de ");
    Serial.print(distancia);
    Serial.println(" cm.");
  }

  Serial.println("Dando o pause.");
  digitalWrite(play,LOW);
  delay(200);
  digitalWrite(play,HIGH);
  digitalWrite(led,LOW);
  boca.write(70);

}

Schematics

circuito ligações
Circuito thanos mmzqf2roqj

Comments

Add projectSign up / Login