Introduction: How to Build an Arduino- Controlled Laser Gun With Recoil (a Work in Progress)

So this all started when I decided I wanted an air rifle. I've always enjoyed target sports and having now gained access to a garden, what better time to treat myself! However, when I started to look at the costs and potential hazards (including living behind a children's nursery), it made me think again. With a background in making random things such as motorised bicycles, fighting robots and drones, I decided to make my own laser rifle controlled by an Arduino board!

As you'll see, it's all very simple stuff and there's probably better ways of doing things but this was a step into the unknown for me as I haven't done any electrical component work for about 10 years, plus I've never done any programming before so bare with me and feel free to comment on ways to improve the end result!

From looking at the title and reading the blurb above, you're probably wondering 'what's he gonna shoot with that?!'. needless to say I'm 0.5 steps ahead of you! The original plan was to complete the rifle then begin making simple arduino targets using other instructables, but then I found this sweet-looking open source target system which uses paper targets and a webcam ( I'm obviously yet to give it a go but it looks much better than anything I was planning......

This is a work in progress so as I build and develop the gun, I'll provide updates and info.

Step 1: The Circuit and Components

The circuit shown in the picture was developed in tinkercad's new circuit creator ( but due to its limitations on how many components they've currently included, I had to improvise a little but I'll provide a better drawing of the actual layout when I can. However, it's allowed me to prove the code and the basics of the wiring:

  • The 3.3v supply is a 3s lipo and associated step-down board that powers the arduino, laser and audio
  • The 24v supply is the same 3s lipo with a voltage booster that powers the solenoid
  • The motor is actually a solenoid
  • The buzzer is the ISD1820 audio board
  • The light bulb is the laser module
  • Arduino Uno is an Arduino pro-mini

So the components that I've used are:

  • PS4 move light gun (perfect for a project like this as it has plenty of built in buttons and is built for both grown-ups and kids alike)
  • 3.3v 8hz Arduino Pro mini
  • 3v 0.85mw green laser (
  • two N-Channel MOSFETs (60V 30A - FQP30N06L)
  • 24v 16kg solenoid (
  • ISD 1820 audio board and speaker (for the blaster sound!)
  • 3s 11.1V 1000mah lipo
  • voltage step-down board that outputs 3.3v
  • voltage booster that outputs 24v
  • .....uF capacitor to help fire the solenoid
  • various resistors

The tools I used are:

  • online 3d printing service
  • breadboard and jumpers
  • soldering iron and kit
  • glue gun
  • sugru
  • 10mm square carbon fibre rod (this doesn't have to be carbon fibre, I had this laying around)
  • Assorted nuts and bolts

Step 2: The Arduino Code

I was fortunate to find someone who pretty much wrote this code for me as I struggled to grasp how to make the gun fire a single blast regardless of how long the trigger is depressed. I'm tweaking the code as I go along so this will change. Overall plan is to have everything running off a single input but the recoil output may move to another pin depending on how the timings work out to keep everything synchronised. You'll see quite a bit of the code is slashed out for the time being.

const int buttonPin = 5; // the number of the pushbutton pin
const int laserPin = 7; // the number of the LED or mosfet/laser pin

//const int recoilpin = 12; // the number of the recoil MOSFET pin

//const int audiopin = 11; // the number of the Audio pin

// variables will change:

int buttonState = 0; // variable for reading the pushbutton status

int buttonStateLast = 0; // variable for recording last button state

void setup()


pinMode(laserPin, OUTPUT); // initialize the laser pin as an output:

//pinMode(recoilpin, OUTPUT); //initialize the recoil pin as an output:

//pinMode(audiopin, OUTPUT); // initialise the audio pin as an output:

pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:


void loop() {

// read the state of the pushbutton value:

buttonState = digitalRead(buttonPin);

// Determine when button pressed . . .

if (buttonState == HIGH and buttonState != buttonStateLast) {

// turn Laser, recoil and audio on:

digitalWrite(laserPin, HIGH);

// digitalWrite(recoilpin, HIGH);

// digitalWrite(audiopin, HIGH);

delay(100); // wait for a tenth of a second

digitalWrite(laserPin, LOW);

// digitalWrite(recoilpin, LOW);

// digitalWrite(audiopin, LOW);


buttonStateLast = buttonState;



Swansong made it!(author)2017-06-30

Thanks for sharing :)

About This Instructable




More by danieljr1:How to Build an Arduino- Controlled Laser Gun With Recoil (a Work in Progress)
Add instructable to: