Lary Lane
Published © GPL3+

Scottish Terrier companion bot

Scott is your new travel companion that sits in any gym bag. It is able to turn its head left and right and bark at random people.

IntermediateFull instructions provided2 days675
Scottish Terrier companion bot

Things used in this project

Hardware components

Scottie dog head papercraft
×1
Gym bag
×1
Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Battery bank USB
×1
Pivot joint, 3D printed
×1
Cardboard box
Must be rigid. I used a delivery box from JLCPCB
×1

Story

Read more

Schematics

Assembly

Inside the bag

Pivot joint

The 3D printed part didn't fit so it broke so I used a piece of plastic instead

Battery bank

Code

Arduino UNO

Arduino
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 75;    // initial servo position in degrees
int rand_sleep_ms = 500; // sleep duration between two head turns
int rand_destination = 75; // destination servo position in degrees
int dir = 0; // direction left(0) or right(1)
  
void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  // Define the movement
  rand_sleep_ms = random(500, 4000);

  dir = ~dir;
  
  if(dir == 0){
    rand_destination = random(50, 75);
  }
  else{
    rand_destination = random(75, 100);
  }
 

  // Execute the movement
  if(pos<rand_destination){
    for (pos = pos; pos <= rand_destination; pos += 1) { // head turn to the right
      // in steps of 1 degree
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15 ms for the servo to reach the position
    }
  }
  else{
    for (pos = pos; pos >= rand_destination; pos -= 1) { // head turn to the left
      // in steps of 1 degree
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15 ms for the servo to reach the position
    }
  }

  delay(rand_sleep_ms);
}

Credits

Lary Lane

Lary Lane

1 project • 1 follower
Thanks to Ecogami.

Comments