I have long wanted to make an interactive artwork, one that responds to and rewards the viewer's attention. To detect a viewer's presence, I first considered a PIR sensor, a simple motion-activated on/off trigger; those are great for animated props. But the LaserPING 2M rangefinder turned out to be the perfect sensor for this project, a proof of concept. The LaserPING does not just detect motion, it measures distance. This allowed me to create a more nuanced response to the viewer, depending on how close they come to the artwork.
From a disinterested distance, the quiet stack of gray squares reveals little (left/top, below) If the viewer approaches within about 2 meters, two squares shift slightly to offer a tiny bit of color. Take another step, and a few more slivers appear. Lean in for a close look, and the piece rewards the viewer's interest as all the panels turn to flash peeks at the bright red base underneath (right/bottom, below). Retreat from the piece, and the squares recompose themselves into their ordered gray arrangement, keeping its true colors hidden until once again a viewer takes a closer look.
The True Colors project was built with six servos mounted inside a 1-1/2 inch deep cradled wood panel, with a small painted canvas panel attached to each servo's horn. A LaserPING))) Rangefinder's output is used to set the servos' positions.
To plan the canvas panel placement, I tried various compositions by just resting the canvases in place and took a quick picture when I was satisfied. The mounting holes were laser cut here at Parallax to fit the servo case and mounting screws (shout out to Kenneth in the machine shop!) A large hole was drilled in the bottom of the frame to run the power cord, and two smaller holes in the top frame to help with hanging.
When mounting the servos, I first removed the servo horns. Then I used stacks of Nylon nuts as spacers, so the servo horns rest at different heights above the wooden front surface. This allows the canvas panels attached to the servo horns to overlap and rotate with minimal collision.
Next, I removed the screw from each servo horn but left it on its spline, then topped it with a piece of foam sticky tape. Finally I pressed each canvas in place. This allows the squares to be removable for painting and for adjusting the servo's default rotation position. Here is the piece disassembled after the painting is complete.
The servos plug into the 3-pin servo ports on the Propeller Activity Board WX, which connects them to Propeller I/O pins P12–P17. BE SURE to put the servo port power jumpers to 5V if you are using wall-mount power supply greater than 6V! The LaserPING rangefinder connects to P0, 3.3 VDC, and Ground with the extension cable, 3-pin header, and jumper wires in the prototyping area.
I used a wall-mount power supply to provide adequate current for all 6 servos to move at once. The LaserPING board is taped to the power cord far down enough so that the rotating canvas squares do not intercept its laser beam and cause it to trigger itself.
CAUTION: If you are using a wall-mount power supply greater than 6 VDC, be sure to put the servo port power jumpers into the 5V position to avoid exposing the servos to more than 6 VDC.
BlocklyProp made programming this artwork very easy. You may download the True Colors.svg file for BlocklyProp Solo, and I explain my approach below.
I decided to have four different servo configurations based on the viewer's position. I divided the LaserPING sensor's detection range into four zones: Far, Middle, and Near, along with a Home zone for when no viewer is detected. I made a 6-element array for each zone, to hold the rotation angle for each of the 6 servos.
By default, the Servo PIN block will move the standard servo quite rapidly to the angle desired. I wanted a slower transition from one canvas panel arrangement to the next. Here's a pro tip: once you've made contact with a Standard servo using the Servo PIN block, you can use the CER servo PIN set ramp step block to slow down its movement from one angle setting to another. So, to initialize the servos, I ran the Home function (we will look at those functions in a bit) and I set the ramp step for each servo to 8, much slower than the default.
The main code is an endless loop that simply measures the distance to the nearest object in the LaserPING sensor's range, if any, and stores that value in the distance variable. Then, If...elseif....else compares distance to four zones Then, the code jumps to a corresponding function, which simply sets the servo angles using the values in the matching array.
Here is the HomeFunction code block, which uses the elements from the Home array to set the servos' angles. In this configuration, the canvas panels are mostly lined up straight to hide all the bright colors.
There are nearly identical blocks named FarFunction, MiddleFunction, and NearFunction, which use their namesake arrays to set their own canvas panel configurations. The Far array values move just two servos slightly away from their Home positions, the Middle array moves two more, and the Near array has the canvas panels all rotating to expose the bright colors underneath.
Of course, this application is not much of a challenge for the Propeller Activity Board WX. I am considering adding sound next, so the viewer has something to hear as well as something to see. Stay tuned!
Links
[1] https://learn.parallax.com/sites/default/files/content/AB-Blockly/Projects/TrueColorsArt/True%20Colors%20Artwork.svg