For many Americans, celebrating Independence Day involves three things: a barbecue, miniature flags, and, of course, fireworks. Not necessarily in that order.

Fireworks are big fun to watch, and creating photographs of them can be even more fun. But to shoot memorable images of pyrotechnics, you’ll need to be willing to adjust settings on your camera and take the time to experiment.

Here are some key techniques for capturing perfect fireworks photos:

Choose the Right Camera and Lens

What’s the right camera for shooting fireworks? The ultimate tool is a DSLR with a variety of flexible manual exposure settings, such as the modestly priced Canon EOS Rebel T5i or the more advanced Nikon D7200.

But many less sophisticated point-and-shoot cameras and even some smartphones offer a fireworks scene mode that should yield good results.

Camera Gear to Consider

Just as important is packing the right lens. “Your lens choice is determined by how far you expect to be from the fireworks display,” says Joe Fitzpatrick, a Florida professional photographer and instructor who specializes in landscape and fine art photography. “Typically, a lens with a wide-to-normal field of view, 18 mm to 55 mm for most consumer DSLRs, is about right.”

Make sure to also take a fully charged spare camera battery. Fitzpatrick explains that long exposures place heavy demands on your camera and can sap its power more quickly than usual. It’s also smart to have extra memory cards, so you can take lots of shots. Finally, take a flashlight just in case you drop a memory card on the ground or can’t see the camera controls in the dark.

Explore Your Camera in Advance

Before the festivities, spend some time getting familiar with your camera. You want to know what the dials and buttons do and exactly where they’re located, so you’re not fumbling around in the dark.

If you have a camera with manual settings, this might be a good time to find the camera’s owner’s manual and figure out how to adjust basic exposure parameters: shutter speed, lens aperture, and ISO.

Many digital cameras, basic and advanced, also give you a simpler option: a fireworks scene mode. This feature automatically adjusts your shutter speed and ISO to capture the festivities. (If your camera doesn’t have a fireworks mode, try the night scene mode.)

One thing you won’t need: your camera’s flash. A camera’s flash isn’t nearly powerful enough to illuminate the night sky, although it does have just enough power to really annoy your neighbors. 

Select a Slow Shutter Speed

If you want a little more creative freedom, ditch the camera’s fireworks scene mode and set the camera to manual mode. This allows you more control over the exposure, including shutter speed, which is all-important for shooting fireworks. 

In most normal daytime photography, your camera will automatically set a shutter speed that’s fast (say, 1⁄125 second) or superfast (1⁄1000 or above). These fast shutter speeds help reduce camera shake and freeze the action, so your images will be sharp and free from blur. 

But if you try to use a fast shutter speed for fireworks, you’ll get nothing but a few small dots of light on a very dark background. The duration of a fireworks burst can be a second or more, so your camera’s shutter speed needs to be correspondingly long.  

To determine the ideal shutter speed, you’ll probably need to need to do a bit of experimentation. At first, set the speed at 1 second, and use your camera’s preview screen to check the results. If the image of the fireworks seems a bit small and underwhelming, try a longer exposure, maybe 2 seconds or even longer. If the image is blurry and indistinct, try a shorter shutter speed of around 1⁄2 second. Take lots of shots and pay attention to which shutter speed settings give you the best results. 

Timing is also important. It’s counterintuitive, but be sure to press the shutter release before the boom, so you capture the light trail that precedes the explosion.

Use Smaller F-Stops and Lower ISO

To enable these longer shutter speeds, you’ll need to adjust the two other key parameters of exposure. Start by dialing down the ISO to 100. (And remember to return it to a more moderate setting, like ISO 400, when you’re shooting a daytime soccer game.)

Then close down the lens aperture to f/8 or f/16, which lets in less light and gives you the added benefit of more depth of field.

At this point, you should also set your camera’s focus to infinity and disable its autofocus. This will stop your camera from readjusting every time you try to take a shot, a common problem when shooting in the dark.

Set Up a Tripod

Because fireworks require superlong shutter speeds, the camera shake when you’re holding a camera can create an ugly blur.

Mounting the camera on a tripod is almost mandatory if you want to achieve a truly sharp image while using a long shutter speed. But if you don’t have a tripod—and are willing to settle for a bit of impressionistic blur—set the camera on something stable, such as a fence and table. Bracing against a pole or a wall can also help. 

“Even though the camera is mounted on a tripod, pressing the shutter button will move the camera, causing camera shake, which will blur the image, and not in a good way,” Fitzpatrick says.

You can reduce the chances of camera shake by using a wireless remote, which is an optional accessory for many DSLRs. If you don’t have a remote, trigger the shutter with the camera’s self timer instead. 

One more thing: Try to find a spot upwind of the fireworks or your shots could be ruined by smoke.

Add Interest in the Foreground

The ideal Fourth of July shot includes more than just the fireworks. 

Instead of restricting your images to only the bombs bursting in air, include the horizon, surrounding landscapes, buildings, or people. Giving your image context will help make it more interesting.

“Fireworks by themselves are nowhere near as impressive as when you have a photograph with fireworks with something in the foreground,” Fitzpatrick says. “For instance, fireworks over water will give you a nice foreground with a reflection.”

Using the fireworks to light the landscape from behind or the side can produce stunning shots. You can even use the fireworks to light portraits of spectators. 

Fitzpatrick says silhouettes of the people watching the fireworks also makes the photo more appealing.

Many advanced cameras let you use various filters, including illustration filters that make photos look like a graphic painting or drawing. 

If you have an iPhone, turn on Live Photos to create a fun, moving image. Or use apps such as Boomerang or Giphy Cam to create gifs of the celebration.