How to make Arduino Laser Turret using Servo motors and Joystick

Arduino Laser Turret, Overview:

In this project, I will demonstrate how to create an Arduino laser turret using servo motors and a two-axis joystick. I will provide the necessary code and a circuit diagram, accompanied by a detailed explanation of the project. This will enable anyone to successfully build the laser turret without encountering any difficulties.

What is Arduino Laser Turret?

This project involves a straightforward device consisting of a bidirectional servo mechanism with a laser module, controlled by a PS2 mode joystick. You might wonder about the practical uses of this project, and the answer depends on the specific application. Let me provide some examples to illustrate its potential usefulness.

Consider a Bluetooth-controlled robot with 4WD capabilities. By attaching a camera to its head, we can not only view the front perspective but also obtain side and top views. The concept behind this project remains the same, although the modules can be interchangeable.

Another application involves incorporating a water sprinkler into a firefighting Arduino robot. By controlling the direction of the water pipe, we can sprinkle water precisely where needed. These examples demonstrate that the project can be applied in various scenarios.

Having introduced the concept, let’s delve into the project stages, which I will explain sequentially to make it easy for you to follow along.


For the servo mechanism part of this project, I have utilized a 3D printer to create the necessary components. If you are new to designing and creating your own 3D prints, there’s no need to worry. I have provided STL files specifically for this project, which you can use to easily fabricate the required parts.

Download 3d Files:

Once you have obtained the STL files for the project, the next step is to prepare them for printing. This involves slicing the design, which can be done using the widely used Cura slicer software. By utilizing Cura, you can convert the 3D model into a format that your 3D printer can understand and print effectively.

The process of printing the parts for this project required a duration of over three hours. In my case, I opted for white PLA filament for the printing material, but you have the flexibility to choose any color that suits your preference. It is essential to ensure that you have selected the adhesion option in your 3D printer settings. Since we are printing three parts simultaneously, it is important to address any potential issues with one part to ensure the successful printing of the other two.

After completing the printing process and obtaining the printed parts, some basic cleaning is required. It is common to observe a web-like structure on the printed parts, as we did not use direct supports during the printing process. Implementing direct supports would add an additional layer of time to the overall printing duration.

You can see the web like structure being cleaned using a hobby knife in the image below.

The process of cleaning and removing the web-like structures from the printed parts might take some time, especially considering that the same process needs to be repeated for all three parts. However, once you have completed the cleaning process, you will end up with the parts that are shown in the image below.

Now that the main mechanism is prepared, it’s time to assemble the various components. To proceed with the assembly, ensure that you have gathered all the necessary components. With the main mechanism ready, we can now move on to the second stage of the project.

We will collect all the materials listed below, as depicted in the accompanying image:

– Arduino Uno
– Jumper wires and breadboard
– Joystick module
– 2 micro servos
– Laser diode
– Arduino IDE

Having gathered these components, we can proceed with the assembly and implementation of the project.

Circuit Diagram For Arduino laser turret:

To simplify the process, let’s go through the circuit building step by step, focusing on each component individually.

There are two main components in this circuit: the micro servos and the PS2 module.

Micro servo connections

The micro servo consists of three pins: two for the power supply, positive (+) and negative (-), and one for the signal. According to the circuit diagram, the positive and negative pins of the two servos are connected to the power rails on the breadboard. The signal pins of the servos are then connected to pins D3 and D4 on the Arduino Uno.

In this project, the servos are responsible for controlling the up-down and swinging actions. The second servo’s horn is equipped with a holder to secure the laser module in place.

Analog joystick module

The joystick module comprises four pins, of which two are dedicated to the power supply, and the remaining two are used for vertical and horizontal control.

For the connections, we connect the positive (+) and negative (-) pins of the joystick module to the power rails of the breadboard. Additionally, the Vrx (vertical) and Vry (horizontal) pins are connected to the A0 and A1 pins on the Arduino Uno board, respectively.

As for the laser diode, it can be directly connected to the power rails on the breadboard, where the +5V and GND pins from the Arduino Uno are connected.

With these connections established, the circuit is complete, and we can proceed to upload the codes to the Arduino Uno.

Arduino laser turret code

Servo servo1; // define servos
Servo servo2;
int joyX = 0; // give variable to joystick readings
int joyY = 1;
int joyVal; // create variable for joystick value
void setup()
servo1.attach(3); // start servos
void loop()
joyVal = analogRead(joyX); // read value from joystick
joyVal = map(joyVal, 0, 1023, 0, 180); // change value range to 0-180
servo1.write(joyVal); // write value to servo
joyVal = analogRead(joyY); // repeat same for y axis
joyVal = map(joyVal, 0, 1023, 0, 180);
delay(20); // add small delay to reduce noise

To upload the code to your Arduino Uno, follow these steps:

1. Connect the programming cable to the Arduino Uno.
2. Open the Arduino IDE.
3. Check the port number and board type by navigating to “Tools” and selecting the appropriate options for “Board Type” and “Ports.”
4. Copy the provided code and paste it into the Arduino IDE.
5. Click on the “Upload” button to initiate the upload process.
6. Once the upload is complete, disconnect the programming cable from the Arduino Uno.

By following these steps, you will successfully upload the code to your Arduino Uno and can proceed with the next stages of the project.

Some basics about the code

We start the code by #include <Servo.h> that means we are telling the IDE to include servo library so that it can understand with what module we are trying to communicate

After this we are calling functions for Joystick and then assigning the pin numbers for servos these are called as


Now, we need to assign values that determine how the servo should respond when it receives input from the joystick module.

joyVal = analogRead(joyX);

joyVal = map(joyVal, 0, 1023, 0, 180);


joyVal = analogRead(joyY);

joyVal = map(joyVal, 0, 1023, 0, 180);



The delay parameter represents the amount of time allocated to the servo. Increasing the delay value results in a slower response, as it allows for smoother movements and helps eliminate any unwanted noise or vibrations.

Final assembly

Once you have successfully uploaded the code, it is crucial to test all the functions to ensure they are working properly. By conducting thorough testing, you can verify that each component and function is functioning as expected. Once you are satisfied with the individual tests, you can proceed to assemble all the components together.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top