This week, the assignment was to create a kinetic sculpture that could be moved with circuitry from a breadboard. I'm not a big sculpture person, more into utilitarian things, so decided to instead make a motion-based toy for my favorite family member, my cat <3.
## Inspiration
Besides the obvious inspiration -- my adorable cat, Peaches -- my inspiration came from existing cat toys. My cat really loves playing with the laser toy, so one option is a motion controlled laser. There are also toys that have a fake mouse running under a sort of fabric. Peaches loves attacking things moving under the blanket (things mostly being people), so this would also be a good option. Other toys that she currently enjoys are tiny puff balls that she kicks and chases around the apartment, stuffed toys that she stomps on, and occassionally feather toys to jump at.
I also looked through a prior student's efforts to make a cat toy here, which is one my cat probably wouldn't like so doesn't seem like the effort of printing out gears and such. The same student did a later project for her cat in week 9 using a servo, which seems more on my wavelength as far as projects go.
Finally, I walked around the lab to get some further inspiration based on what we had laying around and happened upon some pet laser toys, which seemed worth grabbing at least to see what I could do with them.
## Constraints
There are a number of constraints to take into account. The toy should be small because there isn't a lot of free space for it. Also, I want to take durability and safety into account in case the toy attracts Peaches into attacking it. (Though Kassia said I shouldn't worry about durability yet because this doesn't need to end up on the Petco shelves anytime soon.)
## Design
I didn't have time to go through the process of designing and making gears (and frankly didn't have a lot of time this week for the project) so decided to use a servo and the laser to create a moving laser toy. A servo is pretty much a small motor with gears and a potentiometer that can be controlled to a certain position and speed. We have two kinds of servos in the lab, one that can rotate a full 360 degrees and one that rotates 180 degrees. Because I don't want my cat running in circles around the toy -- plus I don't have space for that -- I am using the smraza micro servo 9g S51, which rotates 180 degrees.
The servo has three wires -- the red is for power, brown is for ground, and yellow is for the signal to the Arduino, which I plugged into pin 9 based on the Arduino docs. I also installed the Servo library then got the servo moving back and forth pretty easily using the Arduino Sweep example.
But having the laser move just back and forth isn't terribly exciting, so I decided to play around with the code to have the servo move more randomly. I added five random variables to make the laser move less preditably, so my loop looked like this:
```
void loop() {
int speed1 = random(15,60); // make a random speed
int speed2 = random(15,60);
int pause_ms = random(1500,5000); // have it pause for a few seconds randomly
int min_angle = random(0,90); // specify where the low end of the arc is
int max_angle = random(91,180); // max end of the arc
for (pos = min_angle; pos <= max_angle; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(speed1); // waits at least 15ms for the servo to reach the position
}
delay(pause_ms); // delay before it moves back
for (pos = max_angle; pos >= min_angle; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(speed2); // waits at least 15ms for the servo to reach the position
}
}
```
To attach the laser and keep the servo straight, I made a very janky setup with foam, tape, and a zip tie. But it works!
## Next Steps
The laser is not bright at all, and I tried playing around with different resistors to see if that would fix the issue but it didn't. So I would need to order a brighter laser for it to be a real toy. Also, I'd like to have some sort of enclosure for the laser, maybe after we learn to 3D print I can make one :). And I would want to probably solder wires and heat shrink them so they don't come out when the servo is in motion.