Ready, Aim, and Fire This Sentry Water Gun for Some Summer Fun

This autonomous water cannon uses a LIDAR unit to detect and track obstacles to blast water at, all on its own.

Summer is the season of water fights, and most are done by either throwing water balloons or shooting water out of pressurized nozzles. But what if this method could be upgraded? That's why Marcel created this fun sentry water gun that can autonomously move and blast water at targets. No longer do people have to wait at a hose to fill up their Super Soaker, but can instead simply run in front to enjoy a cool jet of water.

Components

In order to move the cannon, there is a large base containing two stepper motors, a NEMA17 and NEMA23. These rotate the top piece around the X and Z axes to aim the water. There is a hose coming in the side of the base that connects to a 4-way water valve, which is controlled by a 4-channel relay board. Power is supplied by a 12V battery to drive the motors and some electronics, with a DC-DC converter knocking it down to 5V for the relays. The primary controller board is the Minitronics V2.0 that uses a SAM D21 MCU to provide control signals. Finally, there is an RPLidar A1 module that rotates a mirror to generate a 3D map.

LIDAR Operation

LIDAR stands for Light Detecting and Ranging, which operates in a similar manner to radar — bouncing electromagnetic waves off of a surface and waiting for them to return to the point of origin. However, while radar uses invisible microwaves to find objects, LIDAR employs visible light in the form of an often spinning laser or array of laser emitter and detector pairs. By sending out a pulse of light at a target and timing how long it takes to detect an reflection, extremely precise distances can be measured. When this principle is applied to a matrix of individual points, detailed maps can be generated.

Tracking Targets

Distances are being constantly measured by the LIDAR unit, which in turn sends that data via UART to the SAM D21 microcontroller unit. The CMSIS file has a predefined function prototype for one of the UART interrupts, which is later given a definition. This will cause the function to trigger every time new data is sent to the Rx buffer for the SERCOM5 interface. In that function, the distance is read and checked against a predefined threshold. If that number is smaller, then a new target angle and distance are calculated using some trigonometry.

The Code

The start of the code provides numerous definitions for pins, steps to take, ratios, limits, and whether or not to enter debugging mode. In the setup function, pins are set as inputs or outputs, along with initializing serial devices and the two stepper motors via the AccelStepper library. Next, the program enters the main loop, where values are requested from the LIDAR unit. Once the data present flag is set, the SAM D21 takes the previously mentioned angle and distance values and then converts them into X and Y stepper movements, which are then passed to the AccelStepper library to move them. Finally, if there is a target lock, one solenoid at a time is activated to shoot a jet of water.

Operation

As seen in the video below, water fires in an alternating pattern at the closest target, while the platform continually adjusts to maintain its aim.

You can also see in this image how it performs this action. The two stepper motors drive a pair of belts that rotate each axis.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles