Categories
goatee-stroking musing, or something

SimStapler© Simulator

ka-chunk … ka-chunk … ka-chunk … Splendid!

Long ago, the was a thing that called itself “SimStapler©”. It was a very early clicker game: every ten times you clicked on the virtual stapler, you got bonus audio. That was all it did.

It was a simpler time …

A couple of days ago, Lee posted a video with reminded me so much of that virtual stapler:

Since I have the hardware and for various reasons my social calendar isn’t what it was, I set out on the bold plan to make Sim-SimStapler© … or SimStapler© Simulator … or RealStaplerⒹ … or … look, I’ve spent more effort in trying to come up with a name for this than I did making the thing, so call it what you want.

You’ll need a Circuit Playground Express, a couple of alligator clip test leads, and a stapler. And maybe some tape and a paperclip, too

a Circuit Playground Express, a couple of alligator clip test leads, and a stapler
it doesn’t have to be in “I believe you have my stapler” red, but I feel it helps somehow

The important thing about a switch is that it has two electrically isolated parts that come together to close a circuit. And that’s exactly what the Swingline® 747® stapler doesn’t have: its entire metal body and mechanism is electrically conductive. So we have to rig something up …

stapler anvil with tape across it supporting a paperclip, taped down. A green alligator clip is attached to the free end of the alligator clip
Tape, paperclip and alligator clip make up one half of the switch
rear of stapler with white alligator clip protruding, clipped to staple dispenser
… while a handy ledge at the back of the staple dispenser provides a connection for alligator clip #2

Did I say take the staples out yet? No? Take the staples out of the stapler. Possibly even before doing anything else.

The code we’re going to run on the Circuit Playground Express is very simple:

  • Set up pin 1 (helpfully named A7 on the board) as an input. Turn off all the LEDs
  • If pin 1 is shorted to ground, increase a counter and light successive numbers of LEDs round the CPX’s face
  • If the counter reaches 10, play the sample, reset the counter and turn off all the LEDs
  • repeat from “If pin 1 is shorted to ground …” until too bored to continue.

Here’s the code:

# SIM-SimStapler / RealStapler - scruss, 2020-04
# circuitpython on CPX - stapler between D1 (A7) and GND

from adafruit_circuitplayground import cp
import board
from digitalio import DigitalInOut, Direction, Pull
import time

# set up stapler on pin D1 (port A7): goes LOW when pressed
stapler = DigitalInOut(board.D1)
stapler.direction = Direction.INPUT
stapler.pull = Pull.UP

# set up pixels - not too bright
cp.pixels.brightness = 0.1
# turn all pixels off
for i in range(10):
    cp.pixels[i] = (0, 0, 0)

count = 0
while True:
    # stapler pressed, so increase count
    if not stapler.value:
        count = count + 1
        # only count first press, not if held
        while not stapler.value:
            pass
        time.sleep(0.1)

    # light up pixels clockwise for each press
    for i in range(count):
        cp.pixels[9 - i] = (0, 255, 0)

    # get a bonus Penelope Keith every ten presses
    if count == 10:
        cp.play_file("splendid.wav")
        # turn all pixels off after bonus
        for i in range(count):
            cp.pixels[i] = (0, 0, 0)
        # and reset counter for next time
        count = 0

Here’s the code and sample ready to be copied to your CIRCUITPYTHON drive:

(The sample is a slightly tweaked version of Freeverse’s original Bonus.wav. I ran it through an equalizer to make it sound less awful through the CPX’s tinny little speaker. I was also today years old when I found out that the sample wasn’t Penelope Keith from To the Manor Born, but Jen Krasinski, a staffer at Freeverse.)

The connection (singular) is simple:

Alligator clips to A7 (in reality, D1) and GND

Have an appropriate amount of fun!

I suppose I could also have done this on the BrainPad, but I haven’t set it up with MicroPython yet, and I don’t have time to drag coding blocks around. Also, this is not any project to associate with the word “brain” …

If the video doesn’t work: local link.

Leave a Reply

Your email address will not be published. Required fields are marked *