mouse and the billionaire

Thursday the 11th of March, two-Thousand and ten // yet habit--strange thing! what cannot habit accomplish?

Project Links

Catertainer

catertainer

The Catertainer is a prototype / experiment for a new kind of cat toy.

Do your cats get bored with their toys after only a few minutes? Do they miss you when you aren't at home? The Catertainer is the new cat toy for the lonely, bored, and fickle cat. He demands to be played with. If your cat hasn't been playing with him for a while he will start to taunt your cat, making fun and intriguing sounds. If your cat gets too close, the Catertainer will start to shake in fear and his eyes will light up. Add a little catnip to his fur and your cat will go crazy. Best. Cat Toy. Ever.

Video

Promo Video

Cat Test

Circuit Test

Guts

The circuit inside the Catertainer has been miniaturized. Check it out!

catertainer guts

It doesn't get much more compact than that. There's a switch to turn the bad boy on, and a button the side of the container to trigger the sound clips for exhibition purposes.

Concept Art

catertainer conecept art

Code

            

// Catertainer!
// M Bethancourt
// 2008

#define NUMREADINGS 25

int readings[NUMREADINGS];                // the readings from the analog input
int index = 0;                            // the index of the current reading
int total = 0;                            // the running total
int average = 0;                          // the average

int forwardPin = 3;                       // Assign our pins
int recordPin = 0;
int playPin = 6;
int rangeFinder = 0;
int vPin = 10;                             // vibrating motor

int OFF = 255;
int ON = 0;

boolean catNear = false;
int counter = 0;

int closeValue = 0;                       // variable to hold cat distance
   

void setup()
{
  // Turn all windbond pins off
  analogWrite(forwardPin, OFF);
  analogWrite(playPin, OFF);

  Serial.begin(115200);                       //  setup serial
  for (int i = 0; i < NUMREADINGS; i++)
    readings[i] = 0;                        // initialize all the readings to 0

}

void loop() {
  Serial.println(counter);      // how much time has elapsed since I was played with?

  catNear = readIR();

  if (catNear != true){            // if there is no cat around
      if (counter >= 20000){       // and I have been left alone for a while
          taunt();               // I taunt!
          Serial.println("Taunt!");
          counter = 0;             // reset the counter
      }
      counter++;
  } else {                         // Else, I was recently played with
      counter = 0;                 // so let's reset the counter
  }

}

boolean readIR() {
    total -= readings[index];               // subtract the last reading
    readings[index] = analogRead(rangeFinder); // read from the sensor
    total += readings[index];               // add the reading to the total
    index = (index + 1);                    // advance to the next index
    boolean playedWith = false;

    if (index >= NUMREADINGS)               // if we're at the end of the array...
      index = 0;                            // ...wrap around to the beginning

    average = total / NUMREADINGS;          // calculate the average
    // Serial.println(average);                // send it to the computer (as ASCII digits)
    closeValue = average;

    if(closeValue > 150){
      gettinScared();
      catNear = true;
    } else {
      catNear = false;
    }
    return catNear;
}

void stop() {
    analogWrite(forwardPin, OFF);
    analogWrite(recordPin, OFF); 
    analogWrite(playPin, OFF);
    analogWrite(vPin, 0);
}

void taunt() {
    digitalWrite(playPin, ON);
    delay(50);
    analogWrite(vPin, 255);
    delay(5);
    digitalWrite(playPin, OFF);
    analogWrite(vPin, 0);
   

    // Get the next taunt ready
    long taunt = random(1, 10);                    // choose a random taunt
    long i = 0;
    do {
      Serial.println(i);
      digitalWrite(forwardPin, ON);
      digitalWrite(playPin, OFF);
      delay(50);
      digitalWrite(forwardPin, OFF);
      i++;
    } while (i < taunt);
}

void gettinScared() {
    digitalWrite(vPin, HIGH);
    digitalWrite(forwardPin, HIGH);
    digitalWrite(recordPin, HIGH); 
    delay(5);
    analogWrite(vPin, 0);
}

void next() {
    digitalWrite(playPin, HIGH);
    digitalWrite(forwardPin, 0);
    digitalWrite(recordPin, HIGH);
    delay(50); 
    digitalWrite(playPin, 0);
    digitalWrite(forwardPin, HIGH);
    delay(500);
    digitalWrite(playPin, HIGH);
    delay(3000);
    digitalWrite(forwardPin, 0);
}