How to Make a Gun Controlled Lamp




Introduction: How to Make a Gun Controlled Lamp

About: Hello and welcome! My name is Austin. I enjoy creating interesting projects and sharing my projects and ideas with all of you. Please feel free to check out my Youtube channel:…


In this tutorial I will be explaining how I made my gun controlled lamp. The lamp is controlled by an IR remote. You can watch this tutorial on Youtube at:

Parts List:

- Arduino Uno

- 2.1mm plug with a 9V battery clip - 5V relay module

- High torque servo motor (I used a Hitec HS-5755MG) - IR sensor and remote

- Switched 6V battery pack

- 2 L brackets

- Light socket with power chord

- Light bulb - 1 1/2 PVC pipe

- 1 1/2 trap adapter

- Project box

- Lamp shade

- Toy gun

- Hardware/tools

Step 1: Arduino Code

The IRremote library can be downloaded from the following link if you do not already have it.

Also, depending on which IR remote you are using you may have to insert different code values for the buttons on your remote. For example, in the code posted below the value for the OK button on my remote was "0xFF02FD". If you are going to use a different remote than what I used you will need to figure out the proper values for its buttons. You may be able to figure this out by doing some research on google, or you can download an IR decoder sketch. There are many tutorials out there on how to do this.

If you are having troubles with any of this "FoamboardRC" has an excellent instructable on using IR remotes with Arduino. Here is the link to his instructable:


//Gun Lamp
//By: austiwawa
#include <Servo.h> 
#include <IRremote.h>
unsigned long Value1 = 0xFF02FD; // where XXXXXXXX is on our your remote's values (OK button)
int relay_pin = 13;
int recv_pin = 11;
int actual_state = LOW;
// Postions for even, odd clicks
const byte oddPosition = 84;
const byte evenPostion =  40;
int clickCount = 0; // # of clicks
IRrecv irrecv(recv_pin);
decode_results results;
Servo servo1;
void setup() {
  pinMode(relay_pin, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
  servo1.attach(9); // attach servo to digital pin 9
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    if (results.value == Value1) { //  button
      actual_state = (actual_state == LOW) ? HIGH : LOW;
      digitalWrite(relay_pin, actual_state);
    irrecv.resume(); // Receive the next value
    if(results.value == Value1) {
      // increment click count
      // move to even or odd position based on click count
      servo1.write( (clickCount % 2) ? oddPosition : evenPostion);

Step 2:

Be the First to Share


    • Science Fair Challenge

      Science Fair Challenge
    • Stone Concrete Cement Contest

      Stone Concrete Cement Contest
    • Electronics Contest

      Electronics Contest



    6 years ago

    Great idea! It would be even better if the IR remote would be in the gun and the button press would be the trigger of the gun. But You just got yourself a new follower. Keep on making things like this!


    Reply 6 years ago

    I was actually planning on doing that when I thought this project up. But things didnt go as planned. Thank you very much, I appreciate it!


    6 years ago

    I have two questions: You have two #include statements but no referenced libraries. Is that a typo? Also, How did you derive the remote's value for the OK button?


    Reply 6 years ago

    I will also fix the type in the code. Thanks for pointing that out!

    Penolopy Bulnick
    Penolopy Bulnick

    6 years ago

    I really love the combination of the lamp being turned off and it tipping over. Just perfect :)


    Reply 6 years ago

    Thank you very much :) I am happy to hear that you enjoyed it!