A couple of days ago, Lee posted a video with reminded me so much of that virtual stapler:
Today is a stapler switch pic.twitter.com/RkjHWT0Qyn— lee ‘isolation’ cyborg 🛰️ (@Leeborg_) April 22, 2020
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
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 …
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:
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.