Simple Halloween prop

OK, so it looks like I haven’t done anything for ages, but I have, I promise! It’s just that I suck at remembering to post about it after, even though I have all the best intentions to do so. Intentions will only take you so far, though, so let’s get on with a post of something that was whipped up for Halloween.

Blinky, the super easy Halloween prop

For Halloween we had an idea to have eyes in the hedges that would glow and blink so that the trick-or-treaters would feel watched. We had to make this on a super-low budget and we don’t have anything fancy like a 3D printer (I’m open to donations if anyone wants to give me their old 3D printer… just sayin’!) The result (apologies for the shoddy camera work) looks something like this:

And here’s how it was made…

The parts

The main driver for this is a ATTINY85 Digispark modules. I bought a pack of 10 from AliExpress for just $11 (prices vary, though). The boards came with the pins (which we’ll use upside-down from normal). At the same time, I bought a pack of 10 USB to DIP boards for just over $1, some 9v connectors for just under $1 (which you see above I’ve already soldered together), and a bunch of 220 resistors for around 60 cents (all from AliExpress). The LEDs I already had kicking around so I didn’t have to buy those again – these in particular being RGB LEDs. Last but not least is the PCB board I mounted everything on which I got from Amazon. It was a set of 40 pieces, all different sizes, for about £10. I didn’t want most of them, only the size you see above, but I’m sure I’ll be able to find some use for the rest! Oh, I also bought a pack of 10 9v batteries for around $8.50 (I wonder if you can guess from where!)

The assembly

We start to assemble it with the pins. This is where we’re putting them in upside-down for a few reasons. The first is clearance; the plastic riser is the perfect height to match that of the resistor. Secondly, we want a bit more pin on the underside because we’re going to wrap the legs of the resistor around the pin where we’ll solder it on. And lastly, the digispark board is going to sit on top of these pins and we don’t actually need anything else on top, so we don’t need a lot of pin.

I’ve mounted the pins half way across the board and that single pin out there on its lonesome is going to be for the ground. The digispark has a couple more pins than this (vin and +5v), but I wasn’t going to use those so never bothered to pin them up.

Then I soldered the LEDs into place. I put one on each side of the board mirroring each other, because what I effectively ended up doing was putting the LEDs in parallel so they could both run off the same resistor and the same pin, so they’d work in tandem.

At this point, we have a couple LEDs thrust either side of a PCB with some pins in the middle. What we need to do is connect the R, G, and B pins of each LED to the I/O of the digispark – and we’re going to be using pins 0, 1 and 4 for that purpose. From the top, this is what the placement of the resistors looks like:

As you can see, the resistors neatly align with the pins of the digispark and the legs of the LEDs. The flip side of that looks like:

You can probably just make out from that photo that the resistor leg gets wrapped around the LED leg and the digispark pins and soldered in place, with the excess resistor wire snipped off. So then it’s just a matter of hooking the LEDs together with some wire as well as the GND pin. It can be a little fiddly, but it’s not too taxing. I just had some spare wire lying around, hence the odd colour choice for the green/blue legs – and I’m sure your soldering will be far better than mine, too!

Then all that’s left to do it mount the digispark board itself. The only photo I have of that is from an earlier board where I hadn’t quite planned out the wiring, hence you seeing the wires under the digispark rather than being on the underside of the board, but the principle of mounting the board is the same. (The attempt shown in the pictures above is way cleaner, so don’t hold this next image against me!)

As you can see, it’s a pretty neat little package. You can just plug in the 9v battery with the USB connector and away you go… well, almost.

Programming the digispark

Before we can do anything with the board we need to actually tell it what to do. To be able to do this we load up the Arduino IDE and from the board manager we want to add the Digistump AVR Boards, and once added select the Digispark (Default – 16.5mhz) board, and then we can start programming.

I’ve added my code to a GitHub repository, so feel free to fork and improve, but essentially it looks like this:

#define STEPS 40
#define ADJUST 75

#define PIN_R 0
#define PIN_G 1
#define PIN_B 4

float sRGB[3];
float eRGB[3];

void setup()
{
  pinMode(PIN_R, OUTPUT);
  pinMode(PIN_G, OUTPUT);
  pinMode(PIN_B, OUTPUT);
  randomSeed(seedOut(31));
  sRGB[0] = random(0, 255);
  sRGB[1] = random(0, 255);
  sRGB[2] = random(0, 255);
  float p = (float)ADJUST/100;
  eRGB[0] = max(0, min(255, sRGB[0] - (sRGB[0] * p)));
  eRGB[1] = max(0, min(255, sRGB[1] - (sRGB[1] * p)));
  eRGB[2] = max(0, min(255, sRGB[2] - (sRGB[2] * p)));
  on();
}

void loop()
{
  on();
  delay(random(100, 5000));
  if (random(0, 10000) < 3000) {
    fader();
  } else if (random(0, 10000) > 8000) {
    blinker();
  } else if (random(0, 10000) > 9500) {
    blinker();
    delay(350);
    blinker();
  }
}

void fader()
{
  int s = 0;
  while (s++ < STEPS) {
    analogWrite(PIN_R, sRGB[0] + (s * (eRGB[0] - sRGB[0]) / STEPS));
    analogWrite(PIN_G, sRGB[1] + (s * (eRGB[1] - sRGB[1]) / STEPS));
    analogWrite(PIN_B, sRGB[2] + (s * (eRGB[2] - sRGB[2]) / STEPS));
    delay(30);
  }
  while (s--) {
    analogWrite(PIN_R, sRGB[0] + (s * (eRGB[0] - sRGB[0]) / STEPS));
    analogWrite(PIN_G, sRGB[1] + (s * (eRGB[1] - sRGB[1]) / STEPS));
    analogWrite(PIN_B, sRGB[2] + (s * (eRGB[2] - sRGB[2]) / STEPS));
    delay(30);
  }
}

void blinker()
{
  off();
  delay(150);
  on();
}

void on()
{
  analogWrite(PIN_R, sRGB[0]);
  analogWrite(PIN_G, sRGB[1]);
  analogWrite(PIN_B, sRGB[2]);
}

void off() {
  analogWrite(PIN_R, 0);
  analogWrite(PIN_G, 0);
  analogWrite(PIN_B, 0);
}

unsigned long seedOut(unsigned int noOfBits)
{
  unsigned long seed = 0, limit = 99;
  int bit0 = 0, bit1 = 0;
  while (noOfBits--) {
    for (int i = 0; i < limit; ++i) {
      bit0 = analogRead(0)&1;
      bit1 = analogRead(0)&1;
      if (bit1 != bit0) {
        break;
      }
    }
    seed = (seed << 1) | bit1;
  }
  return seed;
}

The setup method sets up our initial random RGB colour and then works our an end value for that for when we want to fade out the brightness a bit. The brightness adjust is controlled by the ADJUST constant and how quickly it fades to that brightness (and back up) is controlled by the STEPS constant.

Now, the digispark board I’m using doesn’t really do random well, so there is a seed routine that attempts to add a bit of randomness there, but I had varying success with it. Your mileage may vary!

There are a few functions there that should hopefully be really obvious in what they’re for; on and off turn the LEDs full on (to the initially created random colour) or turns them off completely. blinker turns the LEDs off and on to give the impression of a blink, and fader fades the LEDs between the initial brightness/colour level and the one that’s calculated given the STEPS and ADJUST values.

loop is the main loop which runs automatically and here we give a number of random options… we have an initial random delay where the LEDs are full on, then it made fade in and out, or it may blink, or it may do a double blink (maybe the spooky eyes are a bit tired, don’t judge!)

programming the board by plugging it right into the USB

Final assembly

OK, so far so good; the board is made, the programming flashed onto the digispark, and things are working. But right now it just looks like the above – two super-bright LEDs on a printed circuit board.

This is where I really wish I had a 3D printer so that I could create some fancy enclosure!

I don’t have one. 🙁

Oh well, Plan B! As these were only going to be out of for a night and it wasn’t going to rain, I decided to go super simple (much like the rest of this build) and put the boards into a black envelop with two eye-holes cut out and a bit of vellum paper taped to the inside.

I figured that once the evening got dark enough, no one would really see the envelop shoved in the hedge, or on the limbs of a tree, or wherever I choose to put them, so it didn’t matter how shoddy my result looked at the time – people would only see the glowing eyes.

As I had made 10 units, I cut different shaped eye holes so they weren’t all the same – variety is the spice of life, apparently.

Thoughts?

Well, for only a few quid per unit I was quite happy with the result. More importantly, my wife was happy with the result and by extension with me, so that’s a win!

The envelop really isn’t a good long-term solution. Even though it didn’t rain, it was a bit clammy which meant the envelops got soft and warn quick quickly. We considered putting them in zip-lock bags, but that caused the eyes to light up the bag, rather ruining the effect.

I also considered getting some white ping-pong balls, cutting holes in them big enough for the LEDs and gluing them on, thereby making some really big eyes. Didn’t get around to trying that, but I bet it would have been great!

What are your thoughts on the project? Any improvements you could offer? Tried something similar? Fancy giving this a go? Would love to hear from you in the comments!

Did you like this? Share it:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.