Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
woodwarddigital
Published © MIT

IR Control Laser Cat Toy

Laser Cat Toy, is this idea sold on you yet?

BeginnerFull instructions provided386
IR Control Laser Cat Toy

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
JustBoom IR Remote
JustBoom IR Remote
Any generic IR remote
×1
IR receiver (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Pan-Tilt HAT
Pimoroni Pan-Tilt HAT
×1
Laser Diode, 2 Pins
Laser Diode, 2 Pins
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Wiring Diagram

Wiring Diagram

Code

IR Controlled Laser Cat Toy

Arduino
Configure Values for IR Remote and upload to your Arduino.
#include <IRremote.h>
#include <Servo.h>
int IRPin = 11;
const int ServoXPin = 9;
const int ServoYPin = 10;

int XValue;
int YValue;
int X_Pos = 90;
int Y_Pos = 90;

IRrecv irrecv(IRPin);
decode_results results;
Servo ServoX;
Servo ServoY;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  ServoX.attach(ServoXPin);
  ServoY.attach(ServoYPin);
  ServoX.write(X_Pos);
  ServoY.write(Y_Pos);
}
void loop()
{
  if (irrecv.decode(&results))
  {
    int value = results.value;
    Serial.println(value);
    switch (value)
    {
      case 25245: //Keypad button "Vol +"
        Serial.println("Move Up");
        Y_Pos = Y_Pos - 15;
        ServoY.write(Y_Pos);
    }
    switch (value)
    {
      case -22441: //Keypad button "Vol -"
        Serial.println("Move Down");
        Y_Pos = Y_Pos + 15;
        ServoY.write(Y_Pos);
    }
    switch (value)
    {
      case 8925: //Keypad button "Pre Track"
        Serial.println("Move Left");
        X_Pos = X_Pos + 15;
        ServoX.write(X_Pos);
    }
    switch (value)
    {
      case -15811: //Keypad button "Next Track"
        Serial.println("Move Right");
        X_Pos = X_Pos - 15;
        ServoX.write(X_Pos);
    }
    irrecv.resume();
  }
}

Credits

woodwarddigital
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.