{"id":16210,"date":"2020-04-25T18:59:07","date_gmt":"2020-04-25T22:59:07","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=16210"},"modified":"2024-01-26T06:18:16","modified_gmt":"2024-01-26T11:18:16","slug":"simstapler-simulator","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2020\/04\/25\/simstapler-simulator\/","title":{"rendered":"SimStapler\u00a9 Simulator"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"SimStapler\u00a9 Simulator - in real life!\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/5KEwg6bWdI8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">ka-chunk \u2026 ka-chunk \u2026 ka-chunk \u2026 <em>Splendid<\/em>!<\/figcaption><\/figure>\n\n\n\n<p>Long ago, the was a thing that called itself <a href=\"https:\/\/web.archive.org\/web\/20080408005431\/http:\/\/www.freeverse.com\/games\/game\/?id=7022\">SimStapler\u00a9<\/a>. It was a very early clicker game: every ten times you <a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/Staple.wav\">clicked<\/a> on the virtual stapler, you got bonus <a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/Bonus.wav\">audio<\/a>. That was all it did.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"157\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/SimStapler-frames.gif\" alt=\"\" class=\"wp-image-16211\"\/><figcaption class=\"wp-element-caption\">It was a simpler time \u2026<\/figcaption><\/figure>\n\n\n\n<p>A couple of days ago, lee posted a video with reminded me so much of that virtual stapler:<\/p>\n\n\n\n<blockquote class=\"twitter-tweet\"><p dir=\"ltr\" lang=\"en\">Today is a stapler switch <a href=\"https:\/\/t.co\/RkjHWT0Qyn\">pic.twitter.com\/RkjHWT0Qyn<\/a><\/p> lee cyborg \ud83e\udd9e\ud83d\udd2d (@Leeborg_) <a href=\"https:\/\/twitter.com\/Leeborg_\/status\/1253067407092039685?ref_src=twsrc%5Etfw\">April 22, 2020<\/a><\/blockquote> <script async=\"\" src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n\n\n\n<p>Since I have the hardware and for various reasons my social calendar isn&#8217;t what it was, I set out on the bold plan to make <em>Sim-<\/em>SimStapler\u00a9\u2026 or SimStapler\u00a9 Simulator \u2026 or RealStapler \u2026 or \u2026 look, I&#8217;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.<\/p>\n\n\n\n<p>You&#8217;ll need a <a href=\"https:\/\/learn.adafruit.com\/adafruit-circuit-playground-express\">Circuit Playground Express<\/a>, a couple of alligator clip test leads, and a stapler. And maybe some tape and a paperclip, too<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-1024x1024.jpg\" alt=\"a Circuit Playground Express, a couple of alligator clip test leads, and a stapler\" class=\"wp-image-16214\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-1024x1024.jpg 1024w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-320x320.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-160x160.jpg 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-768x768.jpg 768w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-1536x1536.jpg 1536w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-2048x2048.jpg 2048w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-1200x1200.jpg 1200w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_132622-1980x1980.jpg 1980w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">it doesn&#8217;t <span style=\"text-decoration: underline;\">have<\/span> to be in \u201c<em><a href=\"https:\/\/www.youtube.com\/watch?v=pHHZBmF8mk4\">I believe you have my stapler<\/a><\/em>\u201d\u009d red, but I feel it helps somehow<\/figcaption><\/figure>\n\n\n\n<p>The important thing about a switch is that it has <span style=\"text-decoration: underline;\">two<\/span> electrically isolated parts that come together to close a circuit. And that&#8217;s exactly what the <a href=\"https:\/\/www.swingline.com\/us\/us\/6453\/s7074736e\/swingline-747-rio-red-stapler-25-sheets-red\">Swingline\u00ae 747\u00ae<\/a> stapler doesn&#8217;t have: its entire metal body and mechanism is electrically conductive. So we have to rig something up \u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-1024x1024.jpg\" alt=\"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\" class=\"wp-image-16215\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-1024x1024.jpg 1024w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-320x320.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-160x160.jpg 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-768x768.jpg 768w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-1536x1536.jpg 1536w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-2048x2048.jpg 2048w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-1200x1200.jpg 1200w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133645-1980x1980.jpg 1980w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Tape, paperclip and alligator clip make up one half of the switch<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-1024x1024.jpg\" alt=\"rear of stapler with white alligator clip protruding, clipped to staple dispenser\" class=\"wp-image-16216\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-1024x1024.jpg 1024w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-320x320.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-160x160.jpg 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-768x768.jpg 768w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-1536x1536.jpg 1536w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553-1200x1200.jpg 1200w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/IMG_20200425_133553.jpg 1538w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u2026 while a handy ledge at the back of the staple dispenser provides a connection for alligator clip #2<\/figcaption><\/figure>\n\n\n\n<p>Did I say take the staples out yet? No? <strong>Take the staples out of the stapler<\/strong>. Possibly even before doing anything else.<\/p>\n\n\n\n<p>The code we&#8217;re going to run on the Circuit Playground Express is very simple:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set up pin 1 (helpfully named <strong>A7<\/strong> on the board) as an input. Turn off all the LEDs<\/li>\n\n\n\n<li>If pin 1 is shorted to ground, increase a counter and light successive numbers of LEDs round the CPX&#8217;s face<\/li>\n\n\n\n<li>If the counter reaches 10, play the sample, reset the counter and turn off all the LEDs<\/li>\n\n\n\n<li>repeat from \u201c<em>If pin 1 is shorted to ground<\/em>\u00a0\u2026\u201d until too bored to continue.<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s the code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# SIM-SimStapler \/ RealStapler - scruss, 2020-04\n# circuitpython on CPX - stapler between D1 (A7) and GND\n\nfrom adafruit_circuitplayground import cp\nimport board\nfrom digitalio import DigitalInOut, Direction, Pull\nimport time\n\n# set up stapler on pin D1 (port A7): goes LOW when pressed\nstapler = DigitalInOut(board.D1)\nstapler.direction = Direction.INPUT\nstapler.pull = Pull.UP\n\n# set up pixels - not too bright\ncp.pixels.brightness = 0.1\n# turn all pixels off\nfor i in range(10):\n    cp.pixels&#x5B;i] = (0, 0, 0)\n\ncount = 0\nwhile True:\n    # stapler pressed, so increase count\n    if not stapler.value:\n        count = count + 1\n        # only count first press, not if held\n        while not stapler.value:\n            pass\n        time.sleep(0.1)\n\n    # light up pixels clockwise for each press\n    for i in range(count):\n        cp.pixels&#x5B;9 - i] = (0, 255, 0)\n\n    # get a bonus Penelope Keith every ten presses\n    if count == 10:\n        cp.play_file(&quot;splendid.wav&quot;)\n        # turn all pixels off after bonus\n        for i in range(count):\n            cp.pixels&#x5B;i] = (0, 0, 0)\n        # and reset counter for next time\n        count = 0\n<\/pre><\/div>\n\n\n<p>Here&#8217;s the code and sample ready to be copied to your <strong>CIRCUITPYTHON<\/strong> drive:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-d45c44e5-9de9-40fa-a134-254fd03adcac\" href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/SimSimStapler.zip\">SimSimStapler.zip<\/a><a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/SimSimStapler.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-d45c44e5-9de9-40fa-a134-254fd03adcac\">Download<\/a><\/div>\n\n\n\n<p>(The sample is a slightly tweaked version of Freeverse&#8217;s original <a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/Bonus.wav\">Bonus.wav<\/a>. I ran it through an equalizer to make it sound less awful through the CPX&#8217;s tinny little speaker. I was also today years old when I found out that the sample wasn&#8217;t <a href=\"https:\/\/www.imdb.com\/name\/nm0445285\/\">Penelope Keith<\/a> from <em>To the Manor Born<\/em>, but Jen Krasinski, a staffer at Freeverse.)<\/p>\n\n\n\n<p>The connection (singular) is simple:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/cpx-connections.jpg\" alt=\"\" class=\"wp-image-16220\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/cpx-connections.jpg 640w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/cpx-connections-320x240.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/cpx-connections-160x120.jpg 160w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption class=\"wp-element-caption\">Alligator clips to <strong>A7<\/strong> (in reality, D1) and <strong>GND<\/strong><\/figcaption><\/figure>\n\n\n\n<p>Have an appropriate amount of fun!<\/p>\n\n\n\n<p>I suppose I could also have done this on the <a href=\"https:\/\/www.brainpad.com\/\">BrainPad<\/a>, but I haven&#8217;t set it up with MicroPython yet, and I don&#8217;t have time to drag coding blocks around. Also, this is not any project to associate with the word \u201cbrain\u201d \u2026<\/p>\n\n\n\n<p>If the video doesn&#8217;t work: <a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/04\/SimStaplerSim-yt.mp4\">local link<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Long ago, the was a thing that called itself SimStapler\u00a9. 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. A couple of days ago, lee posted a video with reminded me so much of that virtual stapler: Today is [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"SimStapler\u00c2\u00a9 Simulator \u00e2\u20ac\u201d in real life! Inspired by @Leeborg_'s stapler switch, I made this with CircuitPython","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[],"class_list":["post-16210","post","type-post","status-publish","format-standard","hentry","category-goatee-stroking-musing-or-something"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4ds","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=16210"}],"version-history":[{"count":7,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16210\/revisions"}],"predecessor-version":[{"id":17500,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16210\/revisions\/17500"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=16210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=16210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=16210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}