Saturday, July 14, 2012

The Arduino in theatre, or why you should be putting computers in your sets.

I've decided that this subject might need to be split into a couple parts, for my own sanity in the organization of information, if nothing else.

For my money, the Arduino is the greatest thing to be available to theatre props and electrics departments for a long time. This $30 board gives anyone with a computer easy access to low-level computing. Microcontrollers have a lot going for them: They're cheap, they're tiny, and you can power them just about however you'd like. Until the development of the Arduino, there was a significant technical barrier to entry. One had to purchase a programmer and deal with datasheets hundreds of pages long. To accomplish basic tasks, registers had to be massaged and timers coaxed.

An example of running an atmega328 on protoboard.
The only support components here are the crystal just
to the right of the chip, the two capacitors, and whatever
you decide to use to provide 5v power.
No more. The Arduino platform offers the user an inexpensive, all-in-one prototyping and development platform. Using the capable Atmega 328, the Arduino offers plenty of I/O, flash and RAM for any prop/practical related purposes. Taking your Arduino projects off the dev board is trivial, and with the ability to purchase mega328 chips with the Arduino bootloader pre-installed for $5.50 (with the required support components costing another few dollars) any number of places online means your projects can fit anywhere you can find space for a small protoboard, available at your local decently-stocked Radio Shack.

A microcontroller is a small computer, built into a single chip. These computers contain everything needed to run programs, and offer basic logic-level outputs and inputs. They can be used for something as simple as blinking some LEDs in a repeated pattern, or as complex as your imagination allows. In the world of theatre, they allow us to build small, low-power dynamic effects that can fit anywhere, be built very quickly, and updated 'in-system' for fine-tuning.

Arduino is programmed with easy-to-read, C++-like syntax called Wiring. Here's a sample, from my latest project:


void increment() {
    for(j = 0; j < 4; j++) 
      values[j] += directions[j]; 
      analogWrite(leds[j], values[j]); 
      delay(10);     
}   
    for(i = 0; i < 4; i++) { 
      if (values[i] < 25 or values[i] > 175) { 
      directions[i] *= -1; 
    }
  }
}

As you can see, if you've done any programming at all in the past, this is pretty straightforward. The really useful additions are commands like 'analogWrite()' which offer easy, one-line access to powerful features of the microcontroller. analogWrite() is used to set a PWM (pulse-width modulation) level to one of the output pins, allowing you to easily dim an LED or control the speed of a motor.

The biggest strength of this approach to dynamic effects, in my mind, is that they can be programmed and put into place, then powered from a dimmer. This means you can have complex effects anywhere you have a free dimmer, without the need to run a control signal. Alternatively, plenty of folks have implemented DMX on the Arduino and other microcontrollers (and this is actually on my list of projects to tackle), meaning you could easily assemble inexpensive automation controllers or anything else you'd like to control from your light console.
Stuff everything in a box and hide it.
In my next post, in the next day or two, I intend to delve into the basic electronics knowledge you'll need to start building the most interesting props and practicals you've ever used. Stay tuned.

No comments:

Post a Comment