April 2022 - June 2022

Nerf Gun
Pen Plotter

For my Mechatronics Class (ME 405), we were assigned a project in which we were to build and program a robot that could draw simple shapes and figures. I worked with one other student to design a 2.5 DOF Nerf Gun Pen Plotter that uses nerf darts to draw pictures on a white board. This plotter utilizes a Nucleo STM32476 microcontroller that interfaces with the TMC4210 serial interface IC and the TMC2208 stepper driver, which we used to control our stepper motors. Commands were sent from our PC to the microcontroller via serial/UART communication. In the following sections, we will discuss the features and implementation of our Nerf Gun Pen Plotter. This project allowed me to gain insights on robot kinematics, computer vision, and the optimization of cooperative, task-based robotic systems.

This robot has two main functionalities. The primary purpose of this robot is to draw some simple shapes. Outside of the scope of the class, an additional feature we added was to use an attached web camera to find and shoot at the color red. For the shape drawing feature, I analyzed the robot geometry and created an algorithm to iteratively solve the angle instructions for the stepper motors using end-effect effector coordinates from 2D vector images. As a team, we further developed a method to concurrently control the Nerf Gun’s firing mechanism and step motor drivers, allowing simultaneous movement and shooting.


The pen plotter takes in an .hpgl file, reads it, and draws the image according to its instructions. In the demonstration shown above, we prepared an image that incorporates both straight lines and curves to demonstrate its drawing capabilities. An overlay of the target image on top of the actual drawn image is shown below.

For the other feature, I developed a computer vision algorithm to detect and shoot at targets. To achieve this functionality, I attached a webcam to the side of the gun and used a program run on the computer to detect the color red with the help of OpenCV modules. Instead of using cartesian coordinates, I opted to use the field of view of the camera to find and send direct angular instructions from the PC to the MCU. This made it easier for the robot to make corrections to its target no matter what its position was.


In our use of the nerf gun, we identified several factors that hindered its effectiveness. The darts tended to deviate significantly from their intended trajectory, which reduced the accuracy of the drawing. This could potentially be improved by adding a longer barrel or by designing our own darts that were more resistant to deformation. Additionally, the size of the darts limited the resolution of our drawings, as a significant spacing was required to avoid collisions. This, combined with the limited capacity of the magazine (18 darts), resulted in frequent reloading, which disrupted the flow of the activity. To overcome these limitations, I would have preferred to design a larger magazine that could hold more darts, as well as improve the adhesion of the darts to their target surfaces. These changes would have enabled smoother and more continuous performance.

Github Project Repo