<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dreamcat]]></title><description><![CDATA[Dreamcat]]></description><link>https://blog.dreamcat.uk</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 14:03:54 GMT</lastBuildDate><atom:link href="https://blog.dreamcat.uk/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TUTORIAL: homemade etch a sketch mouse with Raspberry Pi Pico]]></title><description><![CDATA[I don't have a good explanation for why you'd want to build this
THE DREAM

What if this but computer mouse
Buy the components
You will need:

1x Raspberry Pi Pico. I bought a headered one from thepihut.com for £4.80. Or grab a headerless one if you ...]]></description><link>https://blog.dreamcat.uk/etch-a-sketch-mouse-with-raspberry-pi-pico</link><guid isPermaLink="true">https://blog.dreamcat.uk/etch-a-sketch-mouse-with-raspberry-pi-pico</guid><category><![CDATA[puzzle]]></category><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[Electronics]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Dreamcat]]></dc:creator><pubDate>Mon, 09 Sep 2024 21:07:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1725958970662/09b0e544-5fe4-45d3-ba3c-369a6c1041e5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I don't have a good explanation for why you'd want to build this</p>
<h2 id="heading-the-dream">THE DREAM</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710515841709/80348212-cabe-47ea-9d33-0af5a40ce4e9.jpeg" alt="An Etch-a-sketch toy with a picture of the Taj Mahal drawn on it" class="image--center mx-auto" /></p>
<p>What if this but computer mouse</p>
<h2 id="heading-buy-the-components">Buy the components</h2>
<p>You will need:</p>
<ul>
<li><p>1x Raspberry Pi Pico. I bought a headered one from <a target="_blank" href="https://thepihut.com/products/raspberry-pi-pico">thepihut.com for £4.80</a>. Or grab a headerless one if you like soldering.</p>
</li>
<li><p>1x Micro USB cable. Like the kind you used to use to charge your phone before you got a new phone with a USB-C port. This will connect your USB mouse to your computer.</p>
<ul>
<li><strong>Note:</strong> Not all Micro USB cables are equal; yours needs to be able to carry data as well as power. It'll work for our purposes if when you plug a phone into your computer with it, the computer recognises it as a phone as well as the phone starting to charge. If in doubt, <a target="_blank" href="https://thepihut.com/products/usb-to-micro-usb-cable-0-5m">one of these will do</a>.</li>
</ul>
</li>
<li><p>2x <a target="_blank" href="https://thepihut.com/products/rotary-encoder-extras">Rotary Encoders</a>. Important! Check whether you're looking at a Rotary Encoder or a Potentiometer. Rotary encoders spin all the way around as many times as you like. Potentiometers only go around like 270° of the circle. Look for ones which have a push-button built in.</p>
</li>
<li><p>Some decent jumper wire, I went with <a target="_blank" href="https://thepihut.com/products/thepihuts-jumper-bumper-pack-120pcs-dupont-wire">this pack of dupont wire</a> again from thepihut I swear they aren't paying me</p>
</li>
<li><p>Two (2) of <a target="_blank" href="https://thepihut.com/products/mini-breadboard-white">these lil' mini breadboards</a> and one <a target="_blank" href="https://thepihut.com/products/raspberry-pi-breadboard-half-size">decent sized breadboard</a>, or an equivalent chunk of stripboard if you like soldering</p>
</li>
<li><p>Optional: an LED (any colour) and a resistor (size not that important - I chose a tiddly 330Ω)</p>
</li>
<li><p>A cardboard box. Size? Shape? Whatever. It needs to look like an etch a sketch.</p>
</li>
<li><p>Red poster paint</p>
</li>
<li><p>Silver poster paint, or black and white</p>
</li>
<li><p>Paintbrush</p>
</li>
<li><p>Blu-tak or glue</p>
</li>
<li><p>2x white bottle caps. I used the caps from two cartons of orange juice (with bits, in case you were wondering). Maybe wash them first</p>
</li>
<li><p>A computer, obviously, I don't have any particular recommendations here, you do you</p>
</li>
</ul>
<h2 id="heading-the-build">The build</h2>
<p>Now we at dreamcat take puzzlehunt build quality very seriously, but this isn't a puzzlehunt it's an etch a sketch so we are going with the blue peter approach</p>
<ol>
<li>Paint the box red, preferably on top of a newspaper ad of disapproving Maggie Smith</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710516238422/bb879658-f44d-4f8b-8990-a58caf29de12.jpeg" alt="A rubbish looking cardboard box painted red on some newspaper" class="image--center mx-auto" /></p>
<ol start="2">
<li>Measure out where you want the silver "screen" to go and paint that on in grey. Might need multiple coats</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710516995618/d9d9d6b4-397c-4230-bf62-16c3b4cfd5d8.jpeg" alt="Same box now with silver rectangle painted on" class="image--center mx-auto" /></p>
<ol start="3">
<li>Cut a couple of small holes in the box and screw in the rotary encoders. Mine came with a little nut and ring to hold it neatly in place. Once it's in you can slide on the cap and turn it. It should feel nice and clicky. Click click click</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710516330487/4e71df80-0242-4178-9380-b3456faa4202.jpeg" alt="Same box with a rotary encoder dial sticking out of it" class="image--center mx-auto" /></p>
<ol start="4">
<li><p>Snap each rotary encoder into a lil' breadboard. You'll be sticking your jumper wire in here. Or if you like soldering, stick it in a bit of stripboard and solder it in securely.</p>
<p> Now you might find your rotary encoders have a couple of legs sticking out - if you got the right kind of breadboard those will fit neatly down the trench in the middle, but otherwise you can bend them out of the way with pliers so the board lies flat.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710516580444/36617d45-a059-4f7b-bc91-6423483c90cc.png" alt class="image--center mx-auto" /></p>
<ol start="5">
<li><p>Blu-tak or glue a bottle cap onto the rotary encoder knob so it looks like an etch a sketch</p>
</li>
<li><p>Now I hope you got rotary encoders which have a built-in push button, since we're gonna be using that for the "click". Try pressing the rotary encoder into the box. You feel a click, right? But it probably presses the cardboard in, too. Boo. What you're gonna need to do is find something to brace against the base of the box. I honestly don't know what to suggest to you here. I used two plastic tubs that used to have sauce in, cleaned them up, glued them shut and stuck them to the base of the box. Reduce, reuse, recycle and all that. Now when the lit is shut you can press the rotary encoder in and it feels nice and solid.</p>
</li>
<li><p>Stick your Pi Pico into the bigger breadboard and set it in the middle of the box.</p>
</li>
<li><p>Optional: Stick a lil' LED into the top corner of the box. If you're feeling ultra fancy (and with such high quality cardboard, who wouldn't?) then you can put it in a dedicated plastic holder, like <a target="_blank" href="https://thepihut.com/products/5mm-plastic-bevel-led-holder-pack-of-5">this</a>. I didn't do that. I literally stuck the two legs of the LED through the cardboard.</p>
</li>
</ol>
<h2 id="heading-wiring">Wiring</h2>
<p>Pick yourself some particularly juicy dupont wires and connect up the three circuits you need. They will be:</p>
<ul>
<li><p>The LED, this is the easy one</p>
</li>
<li><p>The rotary encoder button press</p>
</li>
<li><p>The rotary encoder spins</p>
</li>
</ul>
<p>Starting out with the LED: stick a couple of female Dupont wires right on the ends of it. (This is flimsy as heck so if anyone has any better ideas that don't use a whole breadboard up do shout.) Connect one end up to ground and the other to a resistor and thence to pin 15 on your Pico.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725743045318/0b2b37ef-fa33-47ec-b27c-3a165ad47a26.png" alt="Circuit diagram with a Raspberry Pi Pico. Pin 15 connected to a resistor and then to an LED which is connected to ground." class="image--center mx-auto" /></p>
<p>Next it's the button press on the rotary encoder. This is the side of the rotary encoder that only has 2 legs on it. You guessed it - when you click the knob inwards, they connect up. So you just need to connect them each up to a GPIO pin and to ground, respectively. I've chosen GPIOs 12 (for the right knob) and 17 (for the left).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725744315618/0c7356ad-0c1c-4bde-ad7b-9c1efcf741da.png" alt="Circuit diagram with Raspberry Pi Pico and two rotary encoders, only the buttons wired up" class="image--center mx-auto" /></p>
<p>Finally let's do the actual rotary encoders themselves. The way these work is there are 3 pins, two for the turning of the encoder ("A" and "B") and one for ground. Ground is in the middle, A is on the left and B is on the right.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td></td><td>Left encoder</td><td>Right encoder</td></tr>
</thead>
<tbody>
<tr>
<td>A</td><td>GP19</td><td>GP3</td></tr>
<tr>
<td>B</td><td>GP18</td><td>GP4</td></tr>
<tr>
<td>Ground</td><td>GND</td><td>GND</td></tr>
</tbody>
</table>
</div><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725744154943/cc8f6950-8ae0-4cff-93ed-780a315a0f83.png" alt="Circuit diagram with the two rotary encoders attached" class="image--center mx-auto" /></p>
<p>Stick em together what do you get:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725744238716/3d24a5a6-ccef-4073-b4a4-a3cfa47c56b3.png" alt="The complete circuit diagram" class="image--center mx-auto" /></p>
<p>You can now connect your Pi Pico up to the Micro USB cable, thread the other end of the cable through the box lid (make a hole if you need to) and close the box.</p>
<h2 id="heading-software">Software</h2>
<p>OK this is the actual magic bit. We are going to be using a Python library called <a target="_blank" href="https://docs.circuitpython.org/projects/hid/en/latest/">adafruit_hid</a> which lets the pi pico simulate being a Human Interface Device (HID) like a keyboard or a mouse.</p>
<p>First, install CircuitPython on the Pi Pico (the HID library requires this rather than micropython).</p>
<p>(You can skip this bit if you've got CircuitPython already and a preferred editor)</p>
<ol>
<li><p>Download the .uf2 file from <a target="_blank" href="https://circuitpython.org/downloads">https://circuitpython.org/downloads</a></p>
</li>
<li><p>Press and hold the <code>BOOTSEL</code> button on the Pi Pico</p>
</li>
<li><p>While you're holding <code>BOOTSEL</code>, plug the Pi Pico into your computer</p>
</li>
<li><p>It should show up under My Computer, like it was a USB stick.</p>
</li>
<li><p>Copy the .uf2 file onto the Pico drive</p>
</li>
</ol>
<p>Whoa it disappeared!</p>
<p>Well actually it's coming back but this time as a CircuitPython device rather than an empty drive.</p>
<ol start="6">
<li><p>Download <a target="_blank" href="https://codewith.mu/">Mu editor</a></p>
</li>
<li><p>Open Mu. It should recognise you have a Pi Pico plugged in.</p>
</li>
</ol>
<p>Now install the <code>adafruit_hid</code> package. Mu users can follow <a target="_blank" href="https://codewith.mu/en/tutorials/1.2/pypi">this guide</a>.</p>
<h2 id="heading-code">Code</h2>
<p>Copy and paste away:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> digitalio
<span class="hljs-keyword">import</span> board
<span class="hljs-keyword">import</span> usb_hid
<span class="hljs-keyword">from</span> adafruit_hid.mouse <span class="hljs-keyword">import</span> Mouse
<span class="hljs-keyword">import</span> rotaryio

<span class="hljs-comment"># Set up the left hand rotary encoder.</span>
encoder_L = rotaryio.IncrementalEncoder(board.GP19, board.GP18)
last_position_L = <span class="hljs-number">0</span>
button_L = digitalio.DigitalInOut(board.GP17)
button_L.direction = digitalio.Direction.INPUT
button_L.pull = digitalio.Pull.UP
button_L_state = <span class="hljs-literal">None</span>

<span class="hljs-comment"># And the right hand rotary encoder.</span>
encoder_R = rotaryio.IncrementalEncoder(board.GP3, board.GP4)
last_position_R = <span class="hljs-number">0</span>
button_R = digitalio.DigitalInOut(board.GP12)
button_R.direction = digitalio.Direction.INPUT
button_R.pull = digitalio.Pull.UP
button_R_state = <span class="hljs-literal">None</span>

<span class="hljs-comment"># Use adafruit_uid library to set up the Pico as a mouse:</span>
mouse = Mouse(usb_hid.devices)
mouse_speed = <span class="hljs-number">10</span>

<span class="hljs-comment"># Now we have the rest set up, switch on the</span>
<span class="hljs-comment"># indicator light to say the mouse is ready to use:</span>
led = digitalio.DigitalInOut(board.GP15)
led.direction = digitalio.Direction.OUTPUT
led.value = <span class="hljs-literal">True</span>

print(<span class="hljs-string">"start!"</span>)

<span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
    position = encoder_L.position
    <span class="hljs-keyword">if</span> last_position_L != position:
        print(<span class="hljs-string">"L: "</span> + str(position))
        <span class="hljs-comment"># Traditionally on an etch a sketch, the left wheel</span>
        <span class="hljs-comment"># moves horizontally...</span>
        mouse.move((last_position_L - position) * mouse_speed, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>)
    last_position_L = position

    position = encoder_R.position
    <span class="hljs-keyword">if</span> last_position_R != position:
        print(<span class="hljs-string">"R: "</span> + str(position))
        <span class="hljs-comment"># ...and the right wheel moves vertically</span>
        mouse.move(<span class="hljs-number">0</span>, (last_position_R - position) * mouse_speed, <span class="hljs-number">0</span>)
    last_position_R = position

    <span class="hljs-comment"># Left click:</span>
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> button_L.value <span class="hljs-keyword">and</span> button_L_state <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
        button_L_state = <span class="hljs-string">"pressed"</span>
        mouse.press(<span class="hljs-number">1</span>)
    <span class="hljs-keyword">if</span> button_L.value <span class="hljs-keyword">and</span> button_L_state == <span class="hljs-string">"pressed"</span>:
        mouse.release(<span class="hljs-number">1</span>)
        button_L_state = <span class="hljs-literal">None</span>

    <span class="hljs-comment"># Right click:</span>
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> button_R.value <span class="hljs-keyword">and</span> button_R_state <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
        button_R_state = <span class="hljs-string">"pressed"</span>
        mouse.press(<span class="hljs-number">2</span>)
    <span class="hljs-keyword">if</span> button_R.value <span class="hljs-keyword">and</span> button_R_state == <span class="hljs-string">"pressed"</span>:
        mouse.release(<span class="hljs-number">2</span>)
        button_R_state = <span class="hljs-literal">None</span>
</code></pre>
<p>Et voila:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/WfksMA3NKPM">https://youtu.be/WfksMA3NKPM</a></div>
<p> </p>
<p>If you enjoyed this you might enjoy our puzzles, which can be experienced whenever EMF Festival comes around again. None of them are etch a sketch themed though.</p>
]]></content:encoded></item><item><title><![CDATA[How we built a semaphore puzzle]]></title><description><![CDATA[The first in our "anatomy of a puzzle" series...

In 2021, as the pandemic was thawing, we set out to build a new puzzlehunt: The World’s Fair, a Jules Vernian Victorian steampunk adventure. (It eventually morphed into the Octonet puzzlehunt, but tha...]]></description><link>https://blog.dreamcat.uk/how-we-built-a-semaphore-puzzle</link><guid isPermaLink="true">https://blog.dreamcat.uk/how-we-built-a-semaphore-puzzle</guid><category><![CDATA[semaphore]]></category><category><![CDATA[puzzles]]></category><category><![CDATA[puzzle]]></category><category><![CDATA[Escape Rooms]]></category><category><![CDATA[history]]></category><dc:creator><![CDATA[Dreamcat]]></dc:creator><pubDate>Tue, 12 Mar 2024 23:43:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710286930751/f3cc6a8b-87f7-4506-9c7e-2e9b797357ae.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>The first in our "anatomy of a puzzle" series...</em></p>
<p><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcZ5dw2GWtzwYDPL8zv8MUGplEDwQjaNrzwXqVgwvPhpetUzaQy284ms7lXgHY6h2BCncrH4q5fVLGPHIkUxHXcvHJdGV2d6J8ACymmzCEMvf4zoezw-uHNq9t_T-KdeIn1vW1cT3BrTmYrInRlQbs?key=JVfxY49jsiQYxc_Hg1utQQ" alt /></p>
<p>In 2021, as the pandemic was thawing, we set out to build a new puzzlehunt: The World’s Fair, a Jules Vernian Victorian steampunk adventure. (It eventually morphed into the Octonet puzzlehunt, but that’s a whole other story). Our ambition was to capture, across the various puzzles, the spirit and eclectic richness of the era: technological advancement, lightning-fast means of communication, scientific curiosity, dinosaurs, punchcards and the like!</p>
<p><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfUlziiCQFsSp506AMzGUnUWs0xUY8DD06BFscSFeVMzhCHb1racgbobq2LmSWhcYUaLpsV03JfCNqE0iswl2temeMtmz7s2jn9xi8Xtcb3PFtADQEd3DpdG8WhtlBPlHPAto_S1qEos0lXs02KDg?key=JVfxY49jsiQYxc_Hg1utQQ" alt class="image--center mx-auto" /></p>
<p>Communications, in particular, seemed like great puzzle fodder. Having the players use the puzzle mechanics to communicate would mean the puzzle inherently required teamwork (which is always great, since it guarantees everyone will get a chance to take part). Moreover, it captured very well the 19th century zeitgeist: technology as bringing people together and making once impossible things seem easy.</p>
<p>We researched various Victorian era communication technologies: telegraphy, early telephones, optical telegraphs, and flag semaphore. Optical telegraphy seemed the most promising; it was distinctly 19th-century, very alien yet very intuitive, modern-feeling but manifestly obsolete. And most importantly, physical, and hence fun!</p>
<p><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXe2DiazmQsAIl5hZzXzSnTp_J0pDjen2H7CeI99Wklaf8HII8kX_LMGrRbeb1vNV8SlulBxgZGU2msSLdaPMkJE4jMTrqNMMIkRA5Z5TiRfnaSJTQcuMlKGot-F_-rcNQAqZjiLbkv1J4zTPtgBIQ?key=JVfxY49jsiQYxc_Hg1utQQ" alt /></p>
<p>A Wikipedia deep-dive revealed another historical nugget: an early instance of <a target="_blank" href="https://en.wikipedia.org/wiki/Optical_telegraph#History_in_France">wire fraud</a>, perpetrated in 1834 using France’s optical telegraph network. The schemers bribed the optical telegraph operators in Tours to illicitly transmit stock-market information from Paris to Bordeaux, where it would be used to play the Bordeaux stock exchange. The information was encoded in errors deliberately inserted into the telegraph messages otherwise being sent (and hence undetectable to anyone not in-the-know). This seemed like ripe material for a puzzle mechanic.</p>
<p>We still had to figure out how we’d actually force the players to use whatever communication tools we put at their disposal: unless they were really far apart, they’d surely be able to just read the messages aloud to each other. (And if they were too far apart, it would hardly feel like a group activity anymore.) The solution we came up with was asymmetry: the message the sender thought they were transmitting could be entirely different from the one the receiver was reading out. Eventually, we settled on the senders transmitting a single word, letter-by-letter, while the receivers would decode each signal into a word, and the whole transmission into a question. The answer to the question would be the next word to be transmitted along the chain.</p>
<p>Finally, we weaved in the idea of encoding a secret message via deliberate errors, just as the fraudsters of post-Napoleonic France did: each question would include one word that was obviously missing a letter, or including one too many; putting the chain of errors together would produce the final answer.</p>
<p><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfv2QxTB03dRh8-1CPDCqF9pqs2YOgkzXAdyA0gQE2yj4OgUpANOCqDuFmk56FF1gIu0Dp77n_CpXtQPU2l_jkkuEnZwokUzz0gobHFE69_ngsYFNgUPIhm3XtgK_CQgAaD6IDshzD3GSki6Ox-wwI?key=JVfxY49jsiQYxc_Hg1utQQ" alt /></p>
<p>As for the transmission mechanism, we eventually switched from optical telegraphs to flag semaphore (the latter being invented, in 1866, as a hand-held variant of the former). This was simpler to build and, as it turned out, a lot of fun; quite aside from the puzzle mechanics, the players loved waving the flags and spelling out the messages.</p>
<p>All-in-all, we were really happy with how this puzzle turned out. We got players to genuinely engage with a 19th century communications mechanism, weaved in a bit of actual history, while still adding enough twists and turns to make it baffling at first, and rewarding to solve. And the players certainly seemed to enjoy solving the puzzle as much as we enjoyed designing it!</p>
]]></content:encoded></item><item><title><![CDATA[Hello, world!]]></title><description><![CDATA[We are Dreamcat and we are several console errors in a trenchcoat puzzle enthusiasts and hackers who like Lego, dinosaurs, weird musical instruments, cool things, things that go "beep boop", and sharing the secrets to all our puzzles with you here on...]]></description><link>https://blog.dreamcat.uk/hello-world</link><guid isPermaLink="true">https://blog.dreamcat.uk/hello-world</guid><category><![CDATA[dinosaurs]]></category><category><![CDATA[puzzles]]></category><category><![CDATA[lego]]></category><category><![CDATA[General Programming]]></category><category><![CDATA[music]]></category><dc:creator><![CDATA[Dreamcat]]></dc:creator><pubDate>Tue, 12 Mar 2024 23:30:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710288947816/d0de590b-1eff-418e-a1b3-2c8331c7346c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We are Dreamcat and we are <s>several console errors in a trenchcoat</s> puzzle enthusiasts and hackers who like Lego, dinosaurs, weird musical instruments, cool things, things that go "beep boop", and sharing the secrets to all our puzzles with you here on hashnode.</p>
<p>Hold on tight...</p>
]]></content:encoded></item></channel></rss>