Manufaturação industrial
Internet das coisas industrial | Materiais industriais | Manutenção e reparo de equipamentos | Programação industrial |
home  MfgRobots >> Manufaturação industrial >  >> Manufacturing Technology >> Processo de manufatura

Construa um Robô Bípede com Arduino: Guia DIY Baby Dino

Componentes e Materiais

Componente Quantidade
Arduino Mega 2560 (ou Uno/Nano) 1
Bateria 9V (genérica) 1
Sensor Ultrassônico HC-SR04 (SparkFun) 1
Micro-servo SG90 9g 5

Sobre o Projeto

Construa um Robô Bípede com Arduino: Guia DIY Baby Dino

O Baby Dino é um robô de duas pernas baseado em Arduino. Ele basicamente usa cinco motores servo, dois para cada perna e um para a cabeça. Também usa um sensor ultrassônico para detectar obstáculos e evitá-los. Agora, vamos ver como fazê-lo!

Passo 1: Introdução

Passo 2: Componentes Necessários

Passo 3: Fixar os Servos (Calibração)

fix.ino

Passo 4: Design (Corpo de Papelão)

Passo 5: Passo Final

É isso!

uBipedino.ino

Código

fix.ino (Calibração dos Servos)

#include 
Servo s1; Servo s2; Servo s3; Servo s4; Servo s5;

void setup() {
  s1.attach(8);
  s2.attach(9);
  s3.attach(10);
  s4.attach(11);
  s5.attach(12);
}

void loop() {
  s1.write(90);
  s2.write(90);
  s3.write(90);
  s4.write(90);
  s5.write(90);
}

biped (Código Principal do Robô)

Edite os pinos dos servos e do ultrassônico conforme sua conexão.

#include 
#include 

// Edite os pinos conforme sua conexão
#define IRsensorPin 13 // se estiver usando sensor IR em vez de ultrassônico
#define TRIGGER_PIN 12 // Pino Arduino ligado ao trigger do ultrassônico
#define ECHO_PIN 11    // Pino Arduino ligado ao echo do ultrassônico
#define LEFTLEG 7
#define RIGHTLEG 10
#define LEFTFOOT 8
#define RIGHTFOOT 9
#define HEAD 6
#define MAX_DISTANCE 200 // Distância máxima para ping (cm). Máximo do sensor é 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

Servo Lleg, Rleg, Lfoot, Rfoot, Head;

int Hcenter = 70;
int RLcenter = 100;
int RFcenter = 65;
int LLcenter = 90;
int LFcenter = 75;
int tAngle = 30; // ângulo de inclinação
int uAngle = 35; // ângulo de virada
int sAngle = 35; // ângulo de balanço
int hAngle = Hcenter;

void Forward(byte Steps, byte Speed) {
  Serial.println("Forward");
  TiltRightUp(tAngle, Speed);
  for (byte j = 0; j < Steps; ++j) {
    SwingRight(sAngle, Speed);
    TiltRightDown(tAngle, Speed);
    TiltLeftUp(tAngle, Speed);
    SwingRcenter(sAngle, Speed);
    SwingLeft(sAngle, Speed);
    TiltLeftDown(tAngle, Speed);
    TiltRightUp(tAngle, Speed);
    SwingLcenter(sAngle, Speed);
  }
  TiltRightDown(tAngle, Speed);
}

void TurnLeft(byte Steps, byte Speed) {
  Serial.println("TurnLeft");
  TiltLeftUp(uAngle, Speed);
  delay(20);
  for (byte j = 0; j < Steps; ++j) {
    LeftLegIn(sAngle, Speed);
    TiltLeftDown(uAngle, Speed);
    TiltRightUp(uAngle, Speed);
    delay(20);
    LeftLegIcenter(sAngle, Speed);
    RightLegOut(sAngle, Speed);
    TiltRightDown(uAngle, Speed);
    TiltLeftUp(uAngle, Speed);
    delay(20);
    RightLegOcenter(sAngle, Speed);
  }
  TiltLeftDown(uAngle, Speed);
}

void TurnRight(byte Stps, byte Speed) {
  Serial.println("TurnRight");
  TiltRightUp(uAngle, Speed);
  delay(20);
  for (byte f = 0; f <= Stps; ++f) {
    RightLegIn(sAngle, Speed);
    TiltRightDown(uAngle, Speed);
    TiltLeftUp(uAngle, Speed);
    delay(20);
    RightLegIcenter(sAngle, Speed);
    LeftLegOut(sAngle, Speed);
    TiltLeftDown(uAngle, Speed);
    TiltRightUp(uAngle, Speed);
    delay(20);
    LeftLegOcenter(sAngle, Speed);
  }
  TiltRightDown(uAngle, Speed);
}

void HeadRight() {
  Serial.println("HeadRight");
  Head.write(Hcenter - 105);
  delay(1000);
}

void HeadLeft() {
  Serial.println("HeadLeft");
  Head.write(Hcenter + 105);
  delay(1000);
}

void HeadCenter() {
  Serial.println("HeadCenter");
  Head.write(Hcenter);
  delay(1000);
}

void TiltRightUp(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Lfoot.write(LFcenter + i);
    Rfoot.write(RFcenter + i);
    delay(sp);
  }
}

void TiltRightDown(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Lfoot.write(LFcenter + i);
    Rfoot.write(RFcenter + i);
    delay(sp);
  }
}

void TiltLeftUp(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Lfoot.write(LFcenter - i);
    Rfoot.write(RFcenter - i);
    delay(sp);
  }
}

void TiltLeftDown(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Lfoot.write(LFcenter - i);
    Rfoot.write(RFcenter - i);
    delay(sp);
  }
}

void LeftFootUp(char ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Lfoot.write(LFcenter - i);
    delay(sp);
  }
}

void LeftFootDown(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Lfoot.write(LFcenter - i);
    delay(sp);
  }
}

void RightFootUp(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Rfoot.write(RFcenter + i);
    delay(sp);
  }
}

void RightFootDown(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Rfoot.write(RFcenter + i);
    delay(sp);
  }
}

void SwingRight(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Lleg.write(LLcenter - i);
    Rleg.write(RLcenter - i);
    delay(sp);
  }
}

void SwingRcenter(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Lleg.write(LLcenter - i);
    Rleg.write(RLcenter - i);
    delay(sp);
  }
}

void SwingLeft(byte ang, byte sp) {
  for (byte i = 0; i <= ang; i += 5) {
    Lleg.write(LLcenter + i);
    Rleg.write(RLcenter + i);
    delay(sp);
  }
}

void SwingLcenter(byte ang, byte sp) {
  for (byte i = ang; i > 0; i -= 5) {
    Lleg.write(LLcenter + i);
    Rleg.write(RLcenter + i);
    delay(sp);
  }
}

void RightLegIn(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Rleg.write(RLcenter - i);
    delay(sp);
  }
}

void RightLegIcenter(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Rleg.write(RLcenter - i);
    delay(sp);
  }
}

void RightLegOut(byte ang, byte sp) {
  for (int i = 0; i <= ang; i += 5) {
    Rleg.write(RLcenter + i);
    delay(sp);
  }
}

void RightLegOcenter(byte ang, byte sp) {
  for (int i = ang; i > 0; i -= 5) {
    Rleg.write(RLcenter + i);
    delay(sp);
  }
}

void LeftLegIn(byte ang, byte sp) {
  for (byte i = 0; i <= ang; i += 5) {
    Lleg.write(LLcenter + i);
    delay(sp);
  }
}

void LeftLegIcenter(byte ang, byte sp) {
  for (byte i = ang; i > 0; i -= 5) {
    Lleg.write(LLcenter + i);
    delay(sp);
  }
}

void LeftLegOut(byte ang, byte sp) {
  for (byte i = 0; i <= ang; i += 5) {
    Lleg.write(LLcenter - i);
    delay(sp);
  }
}

void LeftLegOcenter(byte ang, byte sp) {
  for (byte i = ang; i > 0; i -= 5) {
    Lleg.write(LLcenter - i);
    delay(sp);
  }
}

void setup() {
  Serial.begin(19200);
  Serial.println("Configuração do Bipedino em execução.");
  Lleg.attach(LEFTLEG);
  Rleg.attach(RIGHTLEG);
  Lfoot.attach(LEFTFOOT);
  Rfoot.attach(RIGHTFOOT);
  Head.attach(HEAD);
  CenterServos();
  delay(500);
  for (int i = 0; i < 5; ++i) {
    GetSonar();
    delay(1000);
  }
  Serial.println("Bipedino está pronto.");
}

void loop() {
  unsigned int cmCenter = MAX_DISTANCE;
  unsigned int cmLeft = MAX_DISTANCE;
  unsigned int cmRight = MAX_DISTANCE;
  
  HeadCenter();
  cmCenter = GetSonar();
  
  if (cmCenter < 20) {
    HeadRight();
    cmRight = GetSonar();
    HeadCenter();
    if (cmRight > 20) {
      TurnRight(1, 30);
    } else {
      HeadLeft();
      cmLeft = GetSonar();
      HeadCenter();
      if (cmLeft > 20) {
        TurnLeft(1, 30);
      }
    }
  } else {
    int nSteps = cmCenter / 5;
    if (nSteps > 5) nSteps = 5;
    else nSteps = 1;
    Serial.print("Passos <");
    Serial.print(nSteps);
    Serial.println(">");
    for (int n = 0; n < nSteps; n++) {
      Forward(1, 30);
    }
  }
}

int GetSonar() {
  unsigned int uS = sonar.ping();
  Serial.print("Ping: ");
  Serial.print(uS / US_ROUNDTRIP_CM);
  Serial.println("cm");
  return uS / US_ROUNDTRIP_CM;
}

void CenterServos() {
  Lleg.write(LLcenter);
  Rleg.write(RLcenter);
  Lfoot.write(LFcenter);
  Rfoot.write(RFcenter);
  Head.write(Hcenter);
  delay(1000);
}

Peças Personalizadas e Caixas

O modelo de recorte para o corpo de papelão está disponível para download.

Esquemático

Construa um Robô Bípede com Arduino: Guia DIY Baby Dino

Processo de manufatura

  1. Chupeta: Design, Normas de Segurança e Insights de Fabricação
  2. Carregadores de Bebê: História, Design e Segurança dos Carregadores Infantis
  3. A Ciência e Mercado de Lenços Umedecidos para Bebê: Materiais, Fabricação e Tendências Futuras
  4. Fórmula Infantil: Ciência, Produção e Perspectivas Futuras
  5. A Evolução e Fabricação de Carrinhos de Bebê: Dos Berços Portáteis aos Carrinhos Modernos
  6. Construa um Spybot Controlado por Bluetooth com Arduino
  7. FlickMote: Controle Remoto IR por Gestos para Casa Inteligente
  8. DIY Arduino TV B-Gone: Controle Remoto Universal para Todas as TVs
  9. Construa um Relógio Mestre LED Personalizado com Alarme – Visível a 12 Metros
  10. Robô Desviador de Obstáculos com Servo: Construa com Arduino e HC-SR04