Capture.jpg

Intro

It’s an automated cat torture device! Ok, not exactly, it’s a 2-axis turret with a cheapo laser pointer mounted in it, run off of a budget microcontroller :) But as shown in the little clip below, my little dude finds it quite entertaining (I actually have to hide it in a drawer if I’m not letting him play with it…I’m actually working on an idea for an upgraded version that I hope will help with this, but who knows if I’ll actually get to it ¯\(ツ)/¯)

IMG_0931.MOV

IMG_0865.jpg

BOM

Printed Parts

Purchased/COTS Parts

Code

I will never pretend to be a competent programmer, so please feel free to talk s*** on my code, but I will say, I was actually kinda proud of the randomization routine I cooked up :)

My apologies for the lack of annotation, but I originally didn’t intend it for others’ eyes (and still am not sure it will see any, haha). But I’m more than happy to answer questions if you reach out to me

#include <Servo.h>;
Servo serRot;
Servo serEl;

int pinRot = 7;
int pinEl = 10;
int pinLas = 5;
int minEl = 100;
int maxEl = 135;
int minRot = 90;
int maxRot = 180;
int nseqEl, nseqRot;
int iseqEl = 0;
int iseqRot = 0;
int stepEl, stepRot;
int signRot, signEl;
int posRot, posEl;

void setup() {
  pinMode(pinLas, OUTPUT);
  pinMode(pinRot, OUTPUT);
  pinMode(pinEl, OUTPUT);
  serRot.attach(pinRot);
  delay(50);
  posRot = (minRot+maxRot)/2;
  serRot.write(posRot);
  delay(100);
  serEl.attach(pinEl);
  delay(50);
  posEl = (minEl+maxEl)/2;
  serEl.write(posEl);
  delay(500);
  nseqRot = random(2, 20);
  nseqEl = random(2, 20);
  signRot = random(0, 1);
  signEl = random(0, 1);
  stepRot = random(1, 20);
  stepEl = random(1, 20);
  digitalWrite(pinLas, HIGH);

}

void loop() {
  if (signRot == 0) {
    posRot = posRot + stepRot;
    if (posRot > maxRot) {
      posRot = posRot - (2 * stepRot);
      signRot = 1;
    }

  } else if (signRot == 1) {
    posRot = posRot - stepRot;
    if (posRot < minRot) {
      posRot = posRot + (2 * stepRot);
      signRot = 0;
    }
  }
  iseqRot = iseqRot + 1;
  if (iseqRot > nseqRot) {
    nseqRot = random(2, 20);
    iseqRot = 0;
  }
  serRot.write(posRot);

if (signEl == 0) {
    posEl = posEl + stepEl;
    if (posEl > maxEl) {
      posEl = posEl - (2 * stepEl);
      signRot = 1;
    }

  } else if (signEl == 1) {
    posEl = posEl - stepEl;
    if (posEl < minEl) {
      posEl = posEl + (2 * stepEl);
      signEl = 0;
    }
  }
  iseqEl = iseqEl + 1;
  if (iseqEl > nseqEl) {
    nseqEl = random(2, 20);
    iseqEl = 0;
  }
  serEl.write(posEl); 
  delay(random(100,500));
  
}

Design Info

Untitled

Untitled

Untitled

Assembly*