While Loops for Photographers


The RICOH THETA V and Z1 can be programmed to do lots of interesting things. You can press one button and make them do many things all at once. This can be a timesaver.

Imagine how you normally take a picture. You pull your camera out of the bag, you point at your subject, you adjust the lens, you move your position or change your angle, you take a picture, you readjust your focus, you take another picture, you look at the subject without the camera, you take another picture.

With a 360 degree camera, you can do all of that with one button press. The secret is a while loop.

Before you say you’re not a programmer, stop right there.

Wouldn’t it be nice if your camera kept taking pictures until it got it right? And then when you’ve gotten enough pictures, stop.

There’s your code.

Simplifying It

To frame the problem simply, I’m going to quantify “enough” pictures as 5 pictures.

I’m also going to fudge the “adjust angle, adjust lens, adjust focus” actions. It’s a 360 degree camera, so you’re already shooting in all directions. No adjustment needed.

Let’s look at the code without the code

Let’s think through the code without worrying about the syntax or where you place it yet. Here it is, in plain English.

You press the shutter button…

While the total number of pictures, which starts at 0 because you haven’t taken any pictures yet, is less than the total you want, which is 5…

Make a light on the camera blink and decide which light on the camera you’ll use, what color the light will be, and how fast it blinks. This is just to give your user information on what’s happening.

  1. Make a sound
  2. Blink a light, in a certain color (yellow), at a certain speed (1 blink per second)
  3. Continue that blinking for 30 seconds
  1. Make the sound again
  2. Make the same light blink, in the same color, but make it blink faster (2 blinks per second)
  3. Blink for 15 seconds
  1. Keep blinking, same color, but really make it blink really fast now (4 blinks per second)
  2. Blink for the last 15 seconds

Take a picture!

Add 1 to the total number of pictures at the beginning of the while loop (happens internally, not visible)

Start over (happens internally, not visible)

After it repeats this sequence 5 times and takes 5 pictures, the while condition (total number of pictures is less than the total you want) will no longer be fulfilled. And you will jump out of the while loop. The while loop is done.

You just completely changed your camera from taking one picture, to taking 5 total, each with a one-minute buildup with flashing lights and beeps to let you know of the timing. It’s a different tool now.

(And you can always jump back out of Plug-in Mode and have your regular THETA doing what it always does.)

The Code

The code has syntax and variables and a couple other things that maybe you don’t know. But it’s doing exactly what the English in the previous section said to do.

Get this fully functional while loop running, and then editing, even for self-proclaimed non-programmers, starts to be pretty fun pretty quickly.

private int currentPicture = 0;
private int maxPicture = 5;
private int delay = 60000;

while (currentPicture < maxPicture) {

 notificationLedBlink(LedTarget.LED3, LedColor.YELLOW, 1000);

 notificationLedBlink(LedTarget.LED3, LedColor.YELLOW, 500);

 notificationLedBlink(LedTarget.LED3, LedColor.YELLOW, 250);


 currentPicture = currentPicture + 1;


Some Ideas

As you can see, you could take out parts of the code and make it do different things.

  1. Change the number of pictures taken. Do you normally need 100 pictures to get the 1 that you want? Set maxPicture to 100.
  2. Change the notifications. Don’t like the sounds because that disturbs the subject? Delete notificationAudioSelf(); in 3 places.
  3. Prefer different colors, purely on aesthetic grounds? Or maybe one color is more visible to you? You can choose MAGENTA, CYAN, RED, WHITE, BLUE.
  4. Use different sounds.
  5. Use different lights on the camera.


Photographers knows cameras best. Applying that understanding to customizing the THETA could make one-touch functionality available to you and maybe a much wider group. Don’t like the idea that you’re “not a programmer” slow you down. The while loop is incredibly powerful and you have a fully functioning version sitting right in front of you.

theta360.guide is here to help. Try building your first while loop today!

Where do I put my while loop?

Your while loop will be part of a THETA plug-in. Building a basic plug-in is just a series of steps, which have been outlined here:

Yes, you’ve got to work through programming steps. But the steps to building a functioning plug-in are well documented. You don’t have to make up any code by yourself.

Then, since you have a fully functioning basic plug-in, add a while loop in the right spot in the code to make the camera take a picture when you hit the shutter button and keep taking pictures until you’ve had enough.