Close
0%
0%

Infrared Controlled Laser Turret

Make a sad cat happy

Similar projects worth following
This project teaches you how to build the software and basic hardware of a IR controlled laser turret. This product can be used to make a sad cat happy.

This project was a school assignment. The objective was to make a sad cat become a happy cat.

Using a laser pointer and servo motors, you can build a small laser pointer turret that is controlled using an infrared receiver. 

The original plan for this project was to have the turret mounted atop a scratching post for maximum fun and happy cats. However due to time constraints and a lack of materials I was only able to get the software built on tinkercad. 

Nonetheless I will still be working to complete this project sometime in the near future.

Sad Cat Circuit Diagram.pdf

Circuit diagram for the main components of the final project.

Adobe Portable Document Format - 152.65 kB - 01/21/2022 at 17:26

Preview
Download

Sad cat controller (1).pdf

Circuit diagram to be used in step 1.

Adobe Portable Document Format - 152.90 kB - 01/21/2022 at 14:56

Preview
Download

  • 1 × Arduino UNO R3 Board
  • 1 × Breadboard + Power pack / USB
  • 1 × Servo Motor
  • 1 × Infrared Receiver + Remote
  • 1 × Arduino Laser

View all 9 components

  • 1
    Building the Servo Controller

    Before we can start using the infrared controller, we need to make the code to control the servos using buttons. This code will be used later and modified to be used with the infrared. 

    Use the following diagram to build the servo controller. This design mimics the controls you will have on the infrared controller later. 

    Parts required include: 1 x Servo Motor, 1 x Arduino UNO R3 Board, 2 x Pushbuttons, 2 x 220 Ω resistors, and connector cables.

    The following code is what I used when assembling the controller.

    #include <Servo.h>               //Include the servo library

    Servo myservo;                     //Make an integer for the Servo

    int val;                                    //Make a value for the rotation
    const int buttonPin = 2;         //Set a state and integer for the left button
    int buttonState = 0;
    const int button2Pin = 3;      //Set a state and integer for the right button
    int button2State = 0;

    void setup()
    {
      myservo.attach(9);                     //Attach the servo to pin 9 
      pinMode(buttonPin, INPUT);     //Set both button 1 and 2 as inputs
      pinMode(button2Pin, INPUT);
      myservo.write(90);                    //Set the rotation value to 90*
    }                                                   // this will be considered the "neutral" state

    void loop()
    {
      buttonState = digitalRead(buttonPin);       //Assign the states of the buttons
      button2State = digitalRead(button2Pin);  // to HIGH or LOW respective to their state
      if (buttonState == HIGH){                           //If the "Left rotate button" is pushed
        val = 150;                                                 // set the rotation value to 150
      }                                                                 // (max 180* modify to your range)
      else if (button2State == HIGH){                //If the "Right rotate button" is pushed
        val = 30;                                                 // set the rotation value to 30 
      }                                                                // (max 0* modify to your range)
      else {                                                        //If neither or pushed reset to the neutral (90*)
        val = 90;
      }
      
      myservo.write(val);                                  //Have the servos rotation match
      delay(15);                                                 // the rotation value
    }

     Copy this code into your program and test it. When you push each button the servo should rotate roughly 45* .

    I have also included the circuit diagram for this step. You can find it under files.

  • 2
    Building the full turret circuit

    Next you'll be putting the full circuit together. This will include 

    2 x Servo Motor, 1 x Arduino UNO R3 Board, 1 x 1 kΩ resistors, an infrared receiver + remote, and connector cables.

    Use the following diagram to complete the Circuitry

    Then you'll want to include the following code:

    #include <IRremote.h>
    #include <Servo.h>

    const byte Reciever = 4;   //Make a constant for the IR Receiver
    const byte LASER = 5;      //Make a constant for the LED (representing the laser)
    Servo TILT;                        //Connect a servo for the angle Tilt
    Servo AIM;                        //Connect a second servo for the rotation Aim
    int val;                               //Make 2 Variables, these are used to set the angle
    int val2;                            // of the servos

    IRrecv irrecv(Reciever);   //Connect the previously constant of the IR Receiver
    decode_results results;  // to the IR remote and determine which button is pressed

    void setup()
    {
        Serial.begin(9600);           //Start the serial monitor
    pinMode(LASER, OUTPUT); //Set the LED as an output
      TILT.attach(3);                      //Attach the servos to their pins
      AIM.attach(2);
        val = 0;
        val2 = 0;
        irrecv.enableIRIn();           //Enable the receiver to "receive" data
    }  

    void loop()
    {
      TILT.write(val);       //Check servo values and
      AIM.write(val2);    // angle the servos to match
      
    if (irrecv.decode(&results))     //If the reciver collects data
      {
        Serial.print("irCode: ");                 //print”irCode: ”
        Serial.print(results.value, HEX);   //print the value in hexdecimal
        Serial.print(", bits: ");                     //print” , bits: ”
        Serial.println(results.bits);            //print the bits
        irrecv.resume();                            //Wait for the next input + data    
      }
      
      if (results.value == 0xFD00FF){   //Power button
        digitalWrite(LASER,HIGH);        //Turn on the laser
        val = 90;                                    //Set servo values 
        val2 = 90;                    
      }
      
      if (results.value == 0xFD40BF)  //Stop function button
      {
        digitalWrite(LASER,LOW);       //Turn everything off
        val = 1;
        val2 = 1;
      }
      
      if (results.value == 0xFD28D7){   // #2 Button
        val = 150;
      }
      
      if (results.value == 0xFD6897){   // #8 Button
        val = 30;
      }
      
      if (results.value == 0xFD8877){   // #6 Button
        val2 = 150;
      }
      
      if (results.value == 0xFD9867){   // #4 Button
        val2 = 30;
      }
      
      if (results.value == 0xFDA857){   // #5 Button
        val = 90;
        val2 = 90;
      }
    }

    Copy this code and run it. If done correctly the buttons should either turn the led on / off, and rotate the servos. The values can be changed to your need. 

    The circuit diagram has also been included.  Unfortunately I have not made a physical build of this project yet, but stay tuned. The future is coming.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates