Project tutorial
Iron Man

Iron Man © GPL3+

In this project, the Iron Man speaks some phrases when you approach.

  • 1,495 views
  • 1 comment
  • 16 respects

Components and supplies

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)
09507 01
Soldering iron (generic)
98h3029 30
Tip Tinner/Cleaner, Lead-Free

Apps and online services

About this project

Iron Man is a fictional comic book character published by Marvel Comics. His true identity is that of businessman and billionaire Tony Stark, who uses high-tech armor in the fight against crime.

Material

  • Arduino Uno
  • 4-channel relay board
  • Ultrasonic module
  • 330 ohm resistor
  • Modulo mini MP3 player
  • Cable p2

Steps

The purpose of this project is to bring an Iron Man doll to life. We use an Ardudino Uno to control everything. When programming, we use the MP3 DFPlayer library and call the function random () to make the choices of the Iron Man audio files.

The audio was taken from Tony Stark's pessimistic films, and were renamed with numbers (001, 002, 003) to be performed by the MP3 module. Link of some auddio files: https://github.com/Sandromesquita/audioIronMan

When a person approaches (about 1.3m), the ultrasonic module identifies and commands the Arduino to call a BURF command (MP3 play command).

Circuit

Lamp circuit

Code

Homem_de_FerroV5.inoArduino
#include <Ultrasonic.h>
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

//Inicia a serial por software nos pinos 10 e 11
SoftwareSerial mySoftwareSerial(6,7); // RX, TX

//Objeto responsvel pela comunicao com o mdulo MP3 (DFPlayer Mini)
DFRobotDFPlayerMini myDFPlayer;

//varivel responsvel por armazenar os comandos enviados para controlar o player
String buf;
//varivel responsvel por armazenar o estado do player (0: tocando ; 1: pausado)
int pausa = 0;
//varivel responsvel por armazenar o estado da equalizao
//varia de 0 a 5
int equalizacao = 0;
//varivel responsvel por armazenar o total de msicas presentes no SD card.
int maxSongs = 0;



#define Gnd  5 // Preto
#define Echo 4 // Laranja com fita preta
#define Trig 3 // Preto com fita preta 
#define Vcc  2 // Laranja

Ultrasonic ultra(Trig,Echo);

int distancia;
/*
 * Rel 1 Cabea 
 * Rel 2 Peito
 * Rel 3 Brao esquerdo
 * Rel 4 Brao direito
 */ 
 #define Cabeca   13
 #define Peito    12
 #define Esquerda 11
 #define Direito  10
 int x=3;
void setup() {
   //Comunicacao serial com o modulo
  mySoftwareSerial.begin(9600);
  //Inicializa a serial do Arduino
  Serial.begin(115200);
 
  //Verifica se o modulo esta respondendo e se o
  //cartao SD foi encontrado
  Serial.println();
  Serial.println("DFRobot DFPlayer Mini");
  Serial.println("Inicializando modulo DFPlayer... (3~5 segundos)");
  if (!myDFPlayer.begin(mySoftwareSerial))
  {
    Serial.println("Nao inicializado:");
    Serial.println("1.Cheque as conexoes do DFPlayer Mini");
    Serial.println("2.Insira um cartao SD");
    while (true);
  }
  Serial.println();
  Serial.println("Modulo DFPlayer Mini inicializado!");

  //Definicoes iniciais
  myDFPlayer.setTimeOut(500); //Timeout serial 500ms
  myDFPlayer.volume(30); //Volume 10
  myDFPlayer.EQ(0); //Equalizacao normal

  //recupera o numero de Msicas encontradas no SD.
  maxSongs = myDFPlayer.readFileCounts(DFPLAYER_DEVICE_SD);
  Serial.println();
  Serial.print("Numero de arquivos no cartao SD: ");
  Serial.println(maxSongs);
  
 
 

 
 
 pinMode(Cabeca,OUTPUT);
 pinMode(Peito,OUTPUT);
 pinMode(Esquerda,OUTPUT);
 pinMode(Direito,OUTPUT);
 
 pinMode(Vcc,OUTPUT);
 pinMode(Gnd,OUTPUT);

 
 digitalWrite(Gnd,LOW );
 digitalWrite(Vcc,HIGH);
 
 digitalWrite(Cabeca,HIGH);
 digitalWrite(Peito,HIGH);
 digitalWrite(Esquerda,HIGH);
 distancia=ultra.Ranging(CM);
}

void loop() {
  Serial.println(String(ultra.Ranging(CM))+" Lendo fora");
  distancia=ultra.Ranging(CM);
  
 
  if((distancia<=150)&&(x==3))
  {
    buf = random(1, 19);
   
  play();
  delay(3000);
  Serial.println("voltei");
  delay(100);
    while(ultra.Ranging(CM)<=150)
    {
      digitalWrite(Esquerda,HIGH); 
      x=2; 
      delay(1200);
    }
  
  }
  else
  {
  digitalWrite(Direito,LOW);
  Serial.println("Nd indentificado");
  x=3;
  }
  
}
void play()
{
  digitalWrite(Direito,HIGH);
  Serial.println("POU");
  delay(300);
  
  digitalWrite(Direito,LOW);
  delay(300);
  
  digitalWrite(Direito,HIGH);
  Serial.println("POU");
  delay(300);
  
  digitalWrite(Direito,LOW);
  delay(300);

  
    //Aguarda a entrada de dados pela serial
  while (Serial.available() >= 0)
  {    
    //Reproducao
    if ((buf.toInt() >= 1) && (buf.toInt() <= maxSongs))
    {

      Serial.print("Reproduzindo musica: ");
      Serial.println(buf.toInt());
//      buf = buf - 48;
      myDFPlayer.play(buf.toInt());
       buf=-1;
      break;
    }
  }
}

Schematics

Mp3 circuit
Homem de ferro bvg7pycljm

Comments

Similar projects you might like

Avenger Assembled: Iron Man Helmet & Arc Reactor

Project tutorial by Gregory O. Voronin and Phil V

  • 6,236 views
  • 6 comments
  • 24 respects

Soldering Iron Controller for Hakko 907

Project tutorial by Alexander

  • 33,343 views
  • 22 comments
  • 71 respects

Soldering Iron Controller for Hakko 907 v.2

Project tutorial by Alexander

  • 26,477 views
  • 175 comments
  • 65 respects

Probability | Autonomous Rover

Project in progress by UniverseRobotics

  • 12,006 views
  • 19 comments
  • 65 respects

Tobor, the Arm

Project showcase by NerdFatherRJ

  • 3,574 views
  • 1 comment
  • 7 respects
Add projectSign up / Login