A local artist asked me if I could build a mechatronic system that would cause “something” to emerge from a piece of art “every so often”. (I’m being vague as it’s not my idea to share.)
I suggested the addition of an PIR (passive infrared) motion sensor so that the “something” could also react to the approach of people.
I am using a SparkFun Arduino compatible Micro-Pro board, due to its small size and built in USB port which can be used for both programming and power. In the video and photos, I’m using a small 9g hobby servo, but I have also tested the same circuit with a standard 3003 size servo. I am powering the SERVO directly from the RAW (red) and GND (black) pins on the MicroPro board (so basically, right from the USB power), and the control line (white) is wired to pin 3 on the board.
The PIR module has three pins. +5V, ground and signal. You provide it with power, and when it detects motion it raises the signal line (it even has a built in pull down resistor on the signal line). I connected it’s (yellow) signal line to pin 5, and ran it’s black line to GND and red line to the VCC connection on the Micro-pro. (Which is actually tied directly to the USB power supply and doesn’t make use of the onboard regulator when the pro-micro is powered via the USB port.)
The code is a small arduino sketch that will sweep the servo when it detects motion, or every X seconds if it doesn’t detect motion, with a configurable “cool down” period after activating. You can download it here: mechatronic.ino.zip
The entire circuit can be powered by a USB cell phone charger. I wanted to be able to make it battery powered simply by plugging in a USB powerbank, but unfortunately, the circuit doesn’t draw enough current when not moving the servo to keep most USB Powerbanks from shutting down due to their “low current auto power off” features.
There are a few USB powerbanks on the market which have an “always on” feature for use with low current devices such as webcams, but you can’t just power it with any USB powerbank.