Here is the video of our final test of our P Comp final project, a cat entertainment device we’re calling MEOWZERS, a device to tease your cat (in a non-sexual way).
In the video you’ll see us operating the device using a sketch that Emily wrote in Processing that features a cute cat cartoon image that serves as a “cursor” that directs the action of the two servos and triggers the laser pointer we embedded into the mouths of one of the four mouse heads that adorn the cat scratching post we modified. Moving the cat icon vertically activates the servo that controls the movement of a feather teaser, causing it to dip and rise to bait the cat to chase it. Moving the cat icon horizontally activates the servo that spins the crown of the scratching post, causing the mouse heads attached to the four posts emanating from the center post to shake in a wild fashion. Pressing the mouse on the computer triggers the laser pointer we embedded into one of the mouse heads. (Emily did a really cool icon to show this effect on the screen.)
Here’s the video of the project in action:
Here’s the Processing Code:
import processing.serial.*;
Serial port; //Create object from Serial class.*;
PImage Cat1;
PImage Cat2;
void setup() {
imageMode(CENTER);
size (700,700);
Cat1 = loadImage(“Cat.jpg”);
Cat2 = loadImage (“Cat2.jpg”);
frameRate(30);
//Open the port that the board is connected to and use the same speed (9600bps)
port = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
background (255);
float newmouseX = map (mouseX, 0, width, 0, 254);
float newmouseY = map (mouseY, 0, height, 0, 254);
port.write((byte)255); //start byte
port.write((byte)newmouseX);
port.write((byte)newmouseY);
if (mousePressed){
image(Cat2, mouseX, mouseY);
port.write((byte)4);
}
else {
image(Cat1, mouseX, mouseY);
port.write((byte)0);
}
}
And the Arduino code:
#include
Servo servoMotor1;
Servo servoMotor2;
int servo1 = 0; //Data received from the serial port
int servoPin1 = 9; //Set value servoPin1 to pin 9
int servo2 = 0; //Data received from the serial port
int servoPin2 = 10; //Set value servoPin2 to pin 10
int button = 0; //Data received from the serial port
int buttonPin = 2; //Set value buttonPin to pin 2
void setup(){
servoMotor1.attach(servoPin1); //Sets pin as OUTPUT
servoMotor2.attach(servoPin2); //Sets pin as OUTPUT
pinMode(buttonPin, OUTPUT); //Sets pin as OUTPUT
Serial.begin(9600); //Start serial communication at 9600bps
}
void loop()
{
if (Serial.available()>= 4){ //If 4 bytes are available to read,
int inByte = Serial.read ();
if (inByte == 255) {
servo1 = Serial.read(); //read serial and store it as val
servo1 = map(servo1, 0, 254, 179, 0);//map servo1 position to val
servo2 = Serial.read(); //read serial and store it as val
servo2 = map(servo2, 0, 254, 179, 0); //map servo2 position to val
button = Serial.read(); //read serial and store it as val
servoMotor1.write (servo1); //move servo1 to position
servoMotor2.write (servo2); //move servo2 to position
if (button == 4){
digitalWrite (buttonPin, HIGH); //turn on laser pointer
}
else{
digitalWrite (buttonPin, LOW); //turn off laser pointer
delay(25);
}
}
}
}
We consider this project to be a smashing success, particularly given how little experience we had with programming prior to this class. It is said that “success has many fathers”, and that is certainly true with this project as many came forward to assist us whenever we ran into problems. We’re extremely grateful to all those who aided us, and our special thanks goes out to:
Jeremy Rotzstain, whose quick tutorial on Processing made our control device possible;
Adam Parrish, who helped us get our feet wet with Processing with his help session;
Todd Holoubek and Rory Nugent, whose suggestions on the P Comp side were invaluable;
Rob Faludi, whose last minute adjustment to our Arduino code literally calmed our jitters by solving the problem of our shaky servos;
Dan Shiffman and Tom Igoe, who kindly loaned me the texts of their two definitive works (Dan’s Learning Processing and Tom’s Making Things Talk );
Tigger Ryan, who did a wonderful job as our “test cat”;
our classmates, whose creativity, ambition, and brilliance inspired our efforts;
and finally, our teacher Scott Fitzgerald, whose calm demeanor, knowledge, generosity, and incisive feedback made this class so pleasurable despite the many frustrations attendant to it.
I would also like to extend my heartfelt thanks to my partner on this project, Emily Ryan, whose patience and good humor kept us on track even while I was fuming about small stuff (like the clocks being off). I did every project in this class with Emily, and while I may have given her cause at times to regret her choice of partners, she never gave me cause to regret mine. Her easygoing manner made working with her a joy, and her design skills covered my deficiencies in that area and made our projects come alive. I’m sure she has great things ahead of her in this program, particularly if she ever learns to overcome her shyness and be a little more outgoing…




































