Skeleton? Check. Arduino? Check. Desire to tinker, enhance and learn? Check! This will be the first part of a multi-series blog on enhancing Steve, our resident skeleton at Conetix. Why a skeleton you ask? The question ended up being “why not!”.

Our workplace has always been different to the usual boring corporate environment, which is why our support staff are always happy when they answer the phone. So, we have a skeleton. However, as this skeleton is static we need to modify and enhance to make him interesting. Ironically this has lined up with Halloween as well!

Part One – PIR Triggered LED eyes

The first enhancement covered in this blog will be to use a Passive Infrared (PIR) sensor controlled by an Arduino controller to turn Steve’s eyes on whenever anyone walks past.

This is a really simple circuit and suitable for Arduino beginners. Parts have been sourced either from eBay or our local Jaycar store.

Parts List

1 x Arduino (or compatible) Controller

2 x red LED’s (we used ZD0156 from Jaycar)

2 x 150 ohm resistors

1 x 1k resistor

1 x 2N2222 transistor

1 x PIR sensor (we used this from eBay)

Various wire, heatshrink and other bits

If you already have an Arduino controller, the total cost will be around $10.

Circuit Design

The first step is to determine the correct current limiting resistor for the LED’s. In this circuit we’re running the LED’s in parallel to simplify the wiring, so we’re going to use two resistors. Using an online calculator for the LED we’ve selected, we need a 150ohm resistor (color bands brown-green-brown-gold) per LED to limit the current to 20ma each.

Since 20ma is right on the limit of what the Arduino can deliver direct from it’s output pins, we’re taking the safer approach of using the 5V Vcc and using a transistor to switch the LED’s on and off. This makes things a little bit more complex, but it’s only two additional parts and less than $1 total. It also means we can easily add more LED’s or go for brighter without any big changes.

For this switching we’re be using the 2N2222 NPN transistor, which will easily handle the current as well as being cheap and easy to find. There’s a wide variety of other suitable NPN transistors (eg like the BC547) easily and cheaply available, so feel free to substitute it.

Finally, we’ve used an Arduino Uno in this example, but it will work on any of the variants. Tehnically we don’t even need the Arduino there to use the PIR for switching we’ve gone with it in order to have custom enhancements.

Arduino Code

Now for the fun part, the coding! If you haven’t already tried a few basic Arduino circuits, I’d suggest having a look at the Getting Started guide on the official Arduino website.

The code is quite simple, since all of the work to determine if the PIR is triggered is within the PIR module itself. Once it has detected motion, it will send the output pin high and we then make the LED’s flash. We also have a turn-on delay, since it takes the PIR a little while to calibrate and stabalise.

Here’s the setup function:

void setup() { Serial.begin(9600); pinMode(pirInputPin, INPUT); pinMode(ledOutputPin, OUTPUT); ledStartup(); Serial.println("Steves Eyes 0.1"); Serial.println("============================="); Serial.print("PIR startup delay..............."); startupDelay(); Serial.println("done!"); }

I had a basic function (ledStartup) to flash the LED’s (aka eyes) at startup and a bit of debug code via the serial port for testing. This code is optional as it has not effect on the normal runtime.

Now for the main loop:

void loop() { if(digitalRead(pirInputPin) == LOW){ analogWrite(ledOutputPin, 0); } else { analogWrite(ledOutputPin, 255); freakyEyes(); delay(2000); } delay(500); }

The main loop fuction reads the output of the PIR pin and if it’s low (no movement dectected), it turns the LED’s off. If it goes high (movement is detected), the LED’s turn on, then pulse in and out (the freakyEyes function) and then finally hold the state for 2 seconds). If there’s been no movement, the LED’s will turn off when the loop runs again and the PIR signal is low.

I’ve also set a delay in the loop of 500ms to both save battery power and give the PIR more of a chance to settle.

The full source code is in the GitHub repo here.

Conclusion

Here’s what Steve looks like:

So, the main question is what we do with Steve next? We have some fun ideas with servos for movement and voice synthesisers to enhance Steveduino further. What are your suggestions? Please leave your ideas in the comments below, we’d love to hear some fun ideas.