Cat Scratching Central

by Amarim25 in Circuits > Arduino

217 Views, 0 Favorites, 0 Comments

Cat Scratching Central

Sad cat.jpeg
Screen Shot 2022-01-23 at 8.10.46 PM.png
IMG_5996.jpg

The Sad Cat Central is a wonderful toy that helps your cat be entertained, distracted and provides a place for it to sleep. In this design there is a place for the cat to go into at the base that is lit up by LED's. At the top is a place to hook up your cats favorite toy so it can spin around on a servo motor for all your cats chasing needs! All of this is confined into a scratching post for your cat to relive stress. To control this tower is simple, just use the buttons on the remote and control the LED pattern or servo pattern. Don't worry if you are not home because the ultrasonic sensor on the side of the post will detect if your cat is near and start all the functions by itself!

Supplies

Screen Shot 2022-01-26 at 10.10.58 AM.png
  • Arduino Uno R3
  • 150 Ω resistors (for max LED brightness on Tinkercad)
  • 1 KΩ resistor
  • 10 kΩ resistor
  • LED's
  • IR sensor
  • IR remote
  • Micro Servo
  • Breadboard
  • Mini breadboard
  • Wires

Breadboard Connections

Screen Shot 2022-01-26 at 10.14.45 AM.png

The first thing you have to do in any circuit is connect the breadboard to power and ground so that all your components can function. The first 2 wires on the left are the ground (black) and power (red) coming from the Arduino. The breadboard in Tinkercad is made so you have to jump the power and ground from bottom to the top so you can use all the ground and power outputs on the breadboard. I did this on the right side of the big breadboard. I also needed more space to fit all my components to I added a second, smaller breadboard to help with organization. When adding another breadboard you have to still get power and ground from somewhere, so I jumped them from the upper rail on the big breadboard.

LED

Screen Shot 2022-01-26 at 10.58.03 AM.png
LED boom.png

The first component I wired was the LED's. When hooking up LED's you have to make sure the flat side is going to negative. The other prong on the led goes to one of the pins on the Arduino. Before the LED goes to the Arduino you have to put a resistor to limit the flow of current to the LED or it will blow up (look at second photo for LED with too much current).

Servo

Screen Shot 2022-01-26 at 1.18.10 PM.png
PWM.png

The next component I added to this circuit is the micro servo that will eventually be attached to a string and ball for the cat to play with. When wiring the servo there are 3 outputs, ground, power and signal. Ground and power, like the other components got to the ground and power rain on the breadboard. The signal has to go into a PWM (second photo) marked with the "~" symbol because PWM (pulse with modulation) is needed to determine the angle of the servo when rotating.

IR Sensor and Remote

Screen Shot 2022-01-26 at 6.44.09 PM.png

The next components added to this circuit is the IR sensor (infrared) and remote. The IR Sensor connects to ground, power and a digital pin in the Arduino. The remote goes along with this sensor, using specific code for each of the buttons that will be later shown in my code in the form of "case" numbers.

Ultrasonic Sensor

Screen Shot 2022-01-26 at 6.54.40 PM.png

The component used to make this project able to work while being away is the ultrasonic sensor. What this does is when the cat comes near the scratching post the circuit will turn on so the cat can play. The Ultrasonic sensor does this buy emitting low frequency radio-waves and when an object comes close the waves will bounce off the object, back at the ultrasonic sensor activating the circuit. The Ultrasonic sensor has 4 pins: ground, power, echo (produces a pulse when reflected signal is released) and trig (triggers ultrasonic sound pulses). Both echo and trig have to be on PWM pins connected to the Arduino due to the fact they use pulses.

Slide Switch

Screen Shot 2022-01-26 at 7.25.07 PM.png

The last component in this project is the slide switch. The slide switch is used to switch between using the IR remote and ultrasonic sensor because both components cant be used at the same time. The slide switch has 3 prongs: terminal 1, common and terminal 2. The 1st terminal is connected to ground via a 10k Ω resistor and to the Arduino. The common pin is connected to power. Finally the terminal 2 pin is also connected to ground but now via a 1k Ω resistor.

Circuit Diagram and Code

Screen Shot 2022-01-26 at 9.00.33 PM.png

#include <Servo.h>

Servo servo;

const int motor = 6;


#include <IRremote.h>

//Define Pins

int redLed = 2;

int blueLed = 3;

int greenLed = 4;

int orangeLed = 5;

int RECV_PIN = 7;

//IR Library stuff

IRrecv irrecv(RECV_PIN);

decode_results results;


const int slider = 8;


int echoPin = 10;

int trigPin = 11;

int trig = 0;


const int redL = 2;

const int blueL = 3;

const int greenL = 4;

const int orangeL = 5;


void setup()

{

 pinMode(redL, OUTPUT);

 pinMode(blueL, OUTPUT);

 pinMode(greenL, OUTPUT);

 pinMode(orangeL, OUTPUT);

 servo.attach(motor);

 servo.write(0);

  

 //Enable serial usage and IR signal in

 Serial.begin(9600);

 Serial.println("Enabling IRin");

 irrecv.enableIRIn(); 

 Serial.println("Enabled IRin");

  

 // turn all the LEDs off

 digitalWrite(redL, LOW);

 digitalWrite(blueL, LOW);

 digitalWrite(greenL, LOW);

 digitalWrite(orangeL, LOW);

  

}


void loop() {

 if (irrecv.decode(&results)) //irrecv.decode(&results) returns true if anything is recieved, and stores info in varible results

 {

  unsigned int value = results.value; //Get the value of results as an unsigned int, so we can use switch case

  Serial.println(value);

  switch (value) 

  {

   case 0xFD08F7: 

    LEDpattern1();

    break;

    

   case 34935:

   LEDpattern2();

    break;

    

   case 18615:

    patternS();

    break;

    

   case 10455:

    patternS2();

    break; 

  }

   

   

  irrecv.resume(); // Receive the next value

 }

}


void LEDpattern1()

{

 digitalWrite(redL, HIGH);

 digitalWrite(blueL, LOW);

 digitalWrite(greenL, HIGH);

 digitalWrite(orangeL, LOW);

 delay(1000);

 digitalWrite(redL, LOW);

 digitalWrite(blueL, HIGH);

 digitalWrite(greenL, LOW);

 digitalWrite(orangeL, HIGH);

 delay(1000);

  

 digitalWrite(redL, HIGH);

 digitalWrite(blueL, LOW);

 digitalWrite(greenL, HIGH);

 digitalWrite(orangeL, LOW);

 delay(1000);

 digitalWrite(redL, LOW);

 digitalWrite(blueL, HIGH);

 digitalWrite(greenL, LOW);

 digitalWrite(orangeL, HIGH);

 delay(1000);

}


void LEDpattern2()

{

digitalWrite(redL, HIGH);

delay(500);

digitalWrite(redL, LOW);



digitalWrite(blueL, HIGH);

delay(500);

digitalWrite(blueL, LOW);



digitalWrite(greenL, HIGH);

delay(500);

digitalWrite(greenL, LOW);



 digitalWrite(orangeL, HIGH);

 delay(500);

 digitalWrite(orangeL, LOW);

  

 digitalWrite(redL, HIGH);

 digitalWrite(blueL, HIGH);

 digitalWrite(greenL, HIGH);

 digitalWrite(orangeL, HIGH);

 delay(1000);

  

 digitalWrite(redL, LOW);

 digitalWrite(blueL, LOW);

 digitalWrite(greenL, LOW);

 digitalWrite(orangeL, LOW);

}

  

void patternS()

{

  motor.write(80);

 delay(1000);

 motor.write(190);

 delay(1000);

 motor.write(60);

 delay(1000);

 motor.write(40);

 delay(1000);

}

  

patternS2()

{

 otor.write(180);

 delay(1000);

 motor.write(90);

 delay(1000);

 motor.write(270);

 delay(1000);

 motor.write(180);

 delay(1000);

}