A 3D Printed Robot Controlled by an Arduino Nano

by brainybotic in Circuits > Arduino

1092 Views, 6 Favorites, 0 Comments

A 3D Printed Robot Controlled by an Arduino Nano

white.png

The main purpose of this project is to put into practice skills from 3D printing, electronics and programming in an appealing way for whom loves these kind of projects.

The robot has a boxy shape for three main reasons: firstly, to make the process of printing easier, i.e., it will not require supports in the printing process. Secondly, it is supposed to be modular, so we can easily swap modules, components and sensors in a way that we can use the robot in a multitude of use cases. And finally, I am planning to launch another version of this robot but mixing it with laser cut technology, to gain more knowledge in that area.

Although I tried to make the assembly project as simple as possible and, for that, chose off the shelf components, there is still some soldering required, mainly for the LED's, that give some expression to the robot face.

Even though the robot may appear simple, I had a lot of trial and error, in the design process, to come to this version of the robot. If you reproduce this project, I hope that, at least, you can enjoy as much as I did, because “It's not the destination, it's the journey”.

Supplies

Tools:

  • 3D Printer
  • Soldering iron

Consumables:

  • 3D print Filament

Components:

  • 2 x SG90 360º Servo Motor
  • 3 x SG90 180º Servo Motor
  • 2 x Wheels for SG90 Servo Motor
  • metalic ball transfer unit.
  • M3 screws
  • M3 square nuts
  • M3 nuts
  • Duponts wires
  • Smile Shark LED Flashlight Power Bank USB (It can any usb powerbank, I chose this one because it has a flashlight)
  • 3 x 7bit rgb ws2812 circular leds. (for the eyes and mouth)

Chassis Assembling

The chassis, supports the entire robot and includes 2 wheels attached, each one to a 360º servo motor and a metallic ball transfer unit.

Front and Back Skin

This front and back parts will have attached to it the arms and head.

Coding

Just a simple program loaded to the arduino nano for testing servos and leds:


#include <FastLED.h>
#include <Servo.h>


Servo servoLeft;
Servo servoRight;
Servo servoArmLeft;
Servo servoArmRight;
Servo servoHead;

int pos0 = 0;


#define LED_PIN     7
#define NUM_LEDS    21
#define EYE_LEFT     14
#define EYE_RIGHT     7
#define MOUTH     0
CRGB leds[NUM_LEDS];
enum lookDirection { FRONT, UP, DOWN, LEFT, RIGHT };


void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  Serial.begin(9600);
  Serial.println(F("Establishing connections..."));

  servoLeft.attach(2);
  servoRight.attach(3);
  servoLeft.attach(4);
  servoRight.attach(5);
  servoHead.attach(6);


  // Servo is stationary.
  servoLeft.write(90);
  servoRight.write(90);
  servoLeft.write(90);
  servoRight.write(90);
  servoHead.write(90);
}

void clearEyes() {
  for (int i = 0; i < 7; i++) {
    leds[EYE_LEFT + i] = CRGB(0, 0, 0);
    leds[EYE_RIGHT + i] = CRGB(0, 0, 0);
  }
}


void clearMouth() {
  for (int i = 0; i < 7; i++) {
    leds[MOUTH + i] = CRGB(0, 0, 0);
  }
}

void openEyes() {
  clearEyes();
  for (int i = 0; i < 7; i++) {
    leds[EYE_LEFT + i] = CRGB(255, 255, 255);
    leds[EYE_RIGHT + i] = CRGB(255, 255, 255);
  }
  FastLED.show();
}

void closeEyes() {
  clearEyes();
  leds[EYE_LEFT + 0] = CRGB(255, 255, 255);
  leds[EYE_LEFT + 3] = CRGB(255, 255, 255);
  leds[EYE_LEFT + 6] = CRGB(255, 255, 255);


  leds[EYE_RIGHT + 0] = CRGB(255, 255, 255);
  leds[EYE_RIGHT + 3] = CRGB(255, 255, 255);
  leds[EYE_RIGHT + 6] = CRGB(255, 255, 255);
  FastLED.show();
}


void look(lookDirection direction) {
  int i = 0;
  switch (direction) {
  case FRONT:
    i = 6;
    break;
  case LEFT:
    i = 5;
    break;
  case RIGHT:
    i = 5;
    break;
  default:
    i = 5;
    break;
  }
  clearEyes();
  leds[EYE_LEFT + i] = CRGB(255, 255, 255);
  leds[EYE_RIGHT + i] = CRGB(255, 255, 255);
  FastLED.show();
}


void smile() {
  clearMouth();
  leds[MOUTH + 0] = CRGB(255, 255, 255);
  leds[MOUTH + 3] = CRGB(255, 255, 255);
  leds[MOUTH + 4] = CRGB(255, 255, 255);
  leds[MOUTH + 5] = CRGB(255, 255, 255);
  FastLED.show();
}


void loop() {
  smile();
  openEyes();
  delay(4000);
  closeEyes();
  delay(500);


  for(pos0=0; pos0 <= 140; pos0++){
    servoLeft.write(pos0);
    delay(10);
    servoRight.write(140 - pos0);
    delay(10);
  }

  // Servo spins forward at full speed for 1 second.
  servoLeft.write(140);
  servoRight.write(140);
  servoArmLeft.write(140);
  servoArmRight.write(140);
  servoHead.write(140);
  delay(1000);
  // Servo is stationary for 1 second.
  servoLeft.write(90);
  servoRight.write(90);
  servoArmLeft.write(90);
  servoArmRight.write(90);
  servoHead.write(90);
  delay(1000);
  // Servo spins in reverse at full speed for 1 second.
  //  myservo.write(0);
  servoLeft.write(50);
  servoRight.write(50);
  servoArmLeft.write(50);
  servoArmRight.write(50);
  servoHead.write(50);
  delay(1000);
  // Servo is stationary for 1 second.
  servoLeft.write(90);
  servoRight.write(90);
  servoArmLeft.write(90);
  servoArmRight.write(90);
  servoHead.write(90);
  delay(1000);
}