Last year Salla made an interactive sculpture as a school project. It’s a golden pig. You drop a coin in the coin slot, it prints you a receipt with wisdom about money out of its mouth. Here’s a video:
I cobbled together the electronics. The pig was re-exhibited at the Art of Research conference and right now it is at TOKYO’s Christmas Sales. Before the exhibition we gave the internals a small update and I thought it’d be nice to write down how it works.
Here are the parts:
Coin detector is a light gate. There’s a red LED that points to a LDR. They’re taped to a chute made out of plywood. The coin slot funnels the coins to the chute and they roll through the light gate, triggering the printing. The first version of the chute was made of cardboard, but it was hard to align the LED and the LDR in a stable way. Plywood is a huge improvement.
Arduino is used as an analog-to-digital converter. It reads the LDR in a loop using the analog input pins and outputs every reading through the serial interface.
Python program on Raspberry Pi reads the measurements from Arduino over USB. When the numbers go below certain threshold, it chooses a random PDF file from a directory and calls
lpr filename.pdf. In the first version, we had a netbook, but I wanted to port this to Raspberry Pi since they’re so trendy.
The printer is Star TSP143, which works great on Linux, although you have to install the drivers yourself. At first I was worried, because there are no drivers for Linux on ARM, but no worries: the drivers come with the source, which was trivial to compile. We chose this printer because it was the only receipt printer we could borrow.
For the new version, I made a program that draws a live graph of the signal, for calibrating the threshold. This was another great improvement - previously I just eyeballed the numbers in the console.
The original design was guided by the fact that I don’t know anything about electronics. I decided to do the simplest thing that could work. Another constraint was to use parts and materials we already had, since we didn’t want to spend any money. It’s nothing fancy, but it works surprisingly well.
There is one known bug: it sometimes double or even triple-prints. I’ll fix it for version 1.2.