Oops! Something went sideways.

Looks like the styling got goofed up. Sorry about that, unless it's what you wanted. If this isn't what you were looking for, try force refreshing your page. You can do that by pressing Shift + F5, or holding Shift and clicking on the "reload" icon. (It's the weird circle arrow thing "⟳" just above this page, usually next to where it says https://blog.unitedheroes.net...)

isn't quite ashamed enough to present

jr conlin's ink stained banana

:: Raspberry Pi, PCA9685, and YOU!

i made a creepy eyeball pumpkin over the weekend. There are lots of how-tos for these sorts of things, so i’m not going to do that. Instead i’m going to offer some lessons-learned.




First, off, i’m a software guy. This is the first time i ever played around with servo motors.

So, let’s start off at the top, shall we?

Aside from the raspberry pi, you’ll need

  • A fake pumpkin big enough to get your hands into (yes, both hands)
  • A box cutter with a fresh blade, because otherwise it’s not going to cut right.
  • A PCA9685 servo controller board. Get the one from Adafruit. Yes, you’ll have to do soldering to add the pins. If you get one that’s already soldered, you’ll still need the Adafruit libraries and documentation, because they’re better than the ones that come with the pre-built boards.
  • 4 strand of Female to Female jumper wires. Really, you should have a bunch of these lying around if you’re going to do stuff with a Pi other than run Pi-Hole or HomeAssistant on it.
  • A hot glue gun and a surprising number of glue sticks
  • 2 bags of 10 full globe plastic eyeballs. Yes, the half eyeballs look better, but they stop looking better once they turn any angle. Yes, it’s more eyeballs than you need. You’re going to screw up a few.
  • About 10 inches of PVC pipe. You will need to bring a sample eyeball with you to make sure it fits inside the pipe.
  • A three AAA battery holder plus connector wire (optional, but since there’s, like, one electronics shop left in the San Jose area that even comes close to having it, it’s a good a reason as any to go to Excess Solutions, which has become the last one standing from Weirdstuff and HSC)
  • Nylon zip ties. (unless you’re planning on hot-gluing the motors to the pipe because you never want to use those motors for anything else ever again.)
  • A roll of 20 gauge bailing wire you bought back in the 80’s and forgot you had until now, but thank you past you for not pitching that.
  • A 1.25″ SpeedBor drill bit you got to add a drain to a sink years ago and also forgot you had but thankfully didn’t pitch or sell.
  • A dremel with one of those drum sander bits.
  • a breathing mask because it turns out that dremel’d off foam gets friggin’ EVERYWHERE.
  • Two cans of compressed air.
  • A shop vac with a reasonably clean filter.
  • A chop saw, rotary sander, laser level and drill press. Ok, like me, you probably don’t have that, and unlike some of the other crap on this list, you’re not going to get those either. So, instead build a bunch of crappy rigs to try and keep a hacksaw straight while wondering if you ever had a proper PVC pipe cutter (you don’t). You’ll also need whatever sandpaper you can find to take all the plastic burrs off the bad saw job you did.

Now for the lessons learned:

  • This is going to take all day. Plan accordingly.
  • Wiring up the PCA board involves you understanding the semi-arcane labeling systems that exist for electronics. Basically, for the Raspberry Pi:
    PCA Pi GPIO post Notes
    GND 6 Ground (also pins 6,9,14,20,25,30,34, or 39
    OE Output Enable (NOT USED)
    SCL 5 (Serial Clock Line)
    SDA 3 (Serial Data Line. No idea why “A” either other than easier to read as tiny print.)
    VCC 1 IC Power (3v also pin 17)
    V+ 2 Servo Power (5v also pin 4)
  • Wire up the boards and add the motors (remember, for the motors, darkest wire is “Ground”) with power off.
  • Once things are wired up, boot up the Pi.
  • Make sure the Pi has the I2C kernel mod loaded (use sudo rpi-config to turn it on).
  • You also want to apt install i2c-tools as well so you can verify that the PCA board is recognized:
    # i2cdetect -y 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: 70 -- -- -- -- -- -- --
    

    No values at 0x40 & 0x70? It’s not there.

  • Drilling holes on the directly opposite side of a ball is not easy. You can build a jig to hold things. i wound up taping a bit of PVC pipe to an old phone book, finding the center, and using a bit of wire as a post to hold it in place. i still screwed up, and that’s why you buy two bags of eyeballs.
  • You will try to be all sorts of clever in how you want to rig up the eyes. Don’t be. Simplicity works better than imagined artistry. (Plus fishing line will NOT cooperate with you trying to emulate eye muscles no matter what elder gods you may invoke.)
  • Make sure every single time you’re about to do something irreversible, that you’re working on the correct side. You can hide some sins, but not all of them.
  • Make the eyeball mounts first. These will take most of the day and be really annoying. Remember to cut more than you think you’ll need because you’re going to screw some of them up.
  • Depending on how bug-eyed you want your eyeballs, you can drill the swivel point deeper or shallower into the lengths of PVC. Mine are around 7.5mm in. Remember what i said about irreversible? Mark which side of the tube is the front. Future you will thank you.
  • Drill all the holes before you start gluing things in place. Each hole will need 45 – 70mm clearance (depending on where the motor is attached). Use a sample eyeball mount to figure out placements. If you’re feeling super clever, you can push a length of wire from the inside out to not where to drill the hole.
  • Did i mention that pumpkin foam gets everywhere? Oh, just wait.
  • Since the shell will be thick (anywhere from 10 to 40mm), you’ll need to dremel out a bunch of it. This will terrify you because it’s a whirring destruction machine and you know your hand is going to slip and destroy everything. Fortunately, this will distract you from the ungodly amount of dust being generated.
  • It’ll be only afterwards as you survey the foamy carnage that you’ll think about setting up the shopvac to suck up the dust being generated.
  • Oh, yeah, and the face mask would have been good too.
  • Place the eyes into the holes and secure them in place with hot glue. Bonus, you want to hold the eye in place with one hand while applying the glue otherwise the damn thing will slip off, or the glue will leak and stick to everything. Check each before everything sets.
  • ProGuy who did it once tip: compressed air will help set the glue quicker that just ambient temperature will.
  • Once all the eyes are in place, try to secure the internal cabling. Don’t try to use blue tape to hold things in place in there because holy hell there’s still ground up foam? You can use bits of blue tape to hold strands of wire together.
  • Plug the eyes back in, pray to whatever gods you have, and power up to check what’s working and what’s not.
  • Tweak the range of movement, because it’s not going to be from 0 to 180. i use 20-160. You’ll know when you no longer have eyeballs that sound like angry bees when they’re resting.

There, that’s it! Wasn’t that easy and fun?

Of course it wasn’t.

Still, if you want to add a light, i found an old LED bike light works pretty well and might even be a bit overpowering.

Blogs of note
personal Christopher Conlin USMC memoirs of hydrogen guy rhapsodic.org Henriette's Herbal Blog
geek ultramookie

Powered by WordPress
Hosted on Dreamhost.