aemkei's xor patterns

Alien Art Drawn With Surprisingly Simple Math

Programmer [aemkei] Tweeted the formula (x ^ y) % 9 alongside code for more “alien art”. But how can a formula as simple as (x ^ y) % 9 result in a complex design? The combination of Bitwise XOR (^) and Modulo (%) generate a repeating pattern that’s still complex enough to satisfy the eye, and it’s ok if that doesn’t sound like an explanation. Bitwise operations are useful when working with memory and shift registers, but also worth learning if you want to drive lines or matrices of LEDs or interpret combinations of multiple switches, or in this case a great way to throw an interesting test pattern up on a new flip-dot display or low-res LED matrix. Are you into it? We are, so let’s jump in.

XOR Truth Table
0b00 0b01 0b10 0b11
0b00 0b00 0b01 0b10 0b11
0b01 0b01 0b00 0b11 0b10
0b10 0b10 0b11 0b00 0b01
0b11 0b11 0b10 0b01 0b00

Bitwise XOR compares each binary digit of the two inputs. The XOR returns a 1 when only one of the two digits is a 1, otherwise, it returns a zero for that position. Let’s say the coordinates were 3, 2. Converted to binary we have 0b11 and 0b10. From this truth table, we can see the most-significant digits are both 1, returning a 0, while only one of the least-significant digits is a 1, so the comparison returns a 1.

Moving onto the %, which is the Modulo operator has nothing to do with percentages. This operator divides two numbers and returns the remainder if any. Take 9 % 5. When dividing 9 by 5, 5 goes in once with a remainder of 4 so 9 % 5 = 4. Now our original formula from the top will draw a black box for every ninth number except that the bitwise XOR throws a wrench into that count, varying how often a number divisible by 9 appears and supplying the complexity necessary for these awesome patterns.

detail of aemkei's xor patterns

What are the most interesting designs can you create in a simple formula?

Hackaday Links Column Banner

Hackaday Links: February 7, 2021

What’s that they say about death and taxes? Apparently that maxim doesn’t apply to Flash, at least when it comes to the taxman. As we noted last week, the end of the Adobe Flash era took with it a scheduling and routing app for the railway system in a Chinese city. This time around, it’s the unfortunately acronymed SARS, for South African Revenue Services, having Flash woes. They still have several online tax forms that haven’t been migrated to HTML5, so to keep the revenue flowing they built their own Flash-enabled browser. Taxpayers are free to download and use the browser while SARS works on getting the rest of their forms migrated. It sort of reminds us of those plans the Internal Revenue Service has to ensure tax collection continues after a nuclear apocalypse — death and taxes indeed.

Trouble for Nintendo in the EU? It looks that way, as consumer groups have made the case to EU regulators that Nintendo’s wildly popular Switch consoles are showing unacceptably premature obsolescence with the notorious “Joy-Con drift” issue. The problem, which manifests as players being unable to control a game due to constant movement despite no inputs on the joystick-like controller, requires a repair, one that Nintendo initially only did for free as warranty service for consoles less than a year old. For consoles out of the warranty period, Nintendo was charging €45, which is approximately the same as what a new controller would cost. This didn’t sit well with regulators, and now they’re breathing down Nintendo’s neck. They now offer free repairs for up to two years, but they’re still under the EU microscope. The interesting bit in the linked document is the technical reason for the problem, which is attributed to premature PCB wear — possibly meaning the traces wear away — and inadequate sealing of the Joy-Con mechanism against dust intrusion.

Last year looked as though it was going to be an exciting one with respect to some of our nearest solar and galactic neighbors. For a while there, it looked like the red giant Betelgeuse was going to go supernova, which would have been interesting to watch. And closer to home, there were some signs of life, in the form of phosphine gas, detected in the roiling atmosphere of our sister planet, Venus. Alas, both stories appear not to have panned out. The much-hoped-for (by me) Betelgeuse explosion, which was potentially heralded by a strange off-cycle dimming of the variable star, seems now to be due to its upper atmosphere cooling by several hundred degrees. As for Venus, the phosphine gas that was detected appears actually to have been a false positive triggered by sulfur dioxide. Disappointing results perhaps, but that’s how science is supposed to work.

Amateur radio often gets a bad rap, derided as a hobby for rich old dudes who just like to talk about their medical problems. Some of that is deserved, no doubt, but there’s still a lot of room in the hobby for those interested in advancing the state of the art in radio communications. In this vein, we were pleased to learn about HamSCI, which is short for Ham Radio Science Citizen Investigation. The group takes to heart one of the stated primary missions of amateur radio as the “ontinuation and extension of the amateur’s proven ability to contribute to the advancement of the radio art.” To that end, they’ll be holding HamSCI Workshop 2021, a virtual conference that will be focused on midlatitude ionospheric science. This appears to be a real science conference where both credentialed scientists and amateurs can share ideas. They’ve got a Call for Proposals now, with abstracts due by February 15. The conference itself will be on March 19 and 20, with free admission. The list of invited speakers looks pretty impressive, so if you have any interest in the field, check it out.

And finally, we got a tip this week about a collection of goofy US patents. Everything listed, from the extreme combover to baby bum-print art, is supposedly covered by a patent. We didn’t bother checking Google Patents, but some of these are pretty good for a laugh. We did look at a few, though, and were surprised to learn that the Gerbil Shirt is not a garment for rodents, but a rodent-filled garment for humans.

The Game Boy Camera, Or: How I Learned To Stop Worrying And Love The Pixels

Never underestimate the power of nostalgia. In an age when there are more megapixels stuffed in the sensor of a smartphone camera than the average computer display can even represent, why would jagged images from a 20-year-old grayscale camera with pixels numbering in the thousands still grab attention? Maybe what’s old is new again, and the coolness factor of novelty is something that can’t be quantified.

The surprise I had last Monday when I saw my Twitter notifications is maybe only second to the feeling I had when I was invited to become a Hackaday contributor. I’d made a very simple web app which mimics a Game Boy Camera using the camera from your phone or desktop, and it got picked up by people so much that I’m amazed my web host is still holding. Let’s look at why something seemingly so simple gained so much traction.

Continue reading “The Game Boy Camera, Or: How I Learned To Stop Worrying And Love The Pixels”

Radio Remote Control Via HTML5

It’s a common scene: a dedicated radio amateur wakes up early in the morning, ambles over to their shack, and sits in the glow of vacuum tubes as they call CQ DX, trying to contact hams in time zones across the world. It’s also a common scene for the same ham to sit in the comfort of their living room, sipping hot chocolate and remote-controlling their rig from a laptop. As you can imagine, this essentially involves a server running on a computer hooked up to the radio, which is connected via the internet to a client running on the laptop. [Olivier/ F4HTB] saw a way to improve the process by eliminating the client software and controlling the rig from a web browser.

[Oliver]’s software, aptly named Universal HamRadio Remote, runs a web server that hosts an HTML5 dashboard for controlling the radio. It also pipes audio back and forth (radio control wouldn’t be very useful if you couldn’t talk!), and can be run on a Raspberry Pi. Not only does this make setup easier, as there is no need to configure the client machine, but it also makes the radio accessible from nearly any modern device.

We’ve seen a similar (albeit expensive and closed-source) solution, the MFJ-1234, before, but it’s always refreshing to see the open-source community tackle a problem and make it their own. We can’t wait to see where the project goes next!

Browser Makes Tiny Office Suite

There’s a recent craze of people living in tiny houses of 400 square feet down to as little as 80 square feet. Maybe [zserge] was thinking about that and created a very tiny office suite in which each tool weighs in at less than 1K. If you are guessing you couldn’t squeeze much functionality in C or C++ code or even assembly, you’d be right. The language of choice? HTML and JavaScript. So while the code is small, it relies on a pretty big piece of software. On the other hand, you have a browser open right now, so the incremental cost of using these tools is very small.

We get the idea that there’s not much chance this is going to sweep the shelves of Microsoft Office, Libre Office, and all the many competitors. However, it is a pretty stunning example of what you can do with modern HTML. There’s even a GitHub repo and a subreddit.

Continue reading “Browser Makes Tiny Office Suite”

LIDAR Built On Familiar Platform

Moore’s law may have reached its physical limit for transistor density, but plenty of other technologies are still on that familiar path of getting smaller and smaller as time passes. It looks like LIDAR is no exception to this trend either. This project from [Owen] shows a fully-functional LIDAR system for about $20 and built almost entirely on top of an ESP32.

The build uses a Time-Of-Flight IR laser range sensor controlled by the ESP32, and the sensor is much smaller than even the ESP32’s footprint so it takes up very little extra space. To get it to function as a LIDAR system instead of just a simple rangefinder it does need a motor in order to rotate itself to see its entire space. Besides its small form factor and low cost, it also has a handy user interface that can run anywhere an HTML5 browser can run, making the use of the system easy and straightforward as well. All of the code is available on the project’s GitHub page.

We wouldn’t expect a system like this to be driving an autonomous car anytime soon, it’s update rate is far too slow, but its intent for small robots and even as an educational demo for learning LIDAR is second to none. If you do need a little more power in a LIDAR system but still don’t want to break the bank, we featured this impressive setup a few weeks ago.

MIT Scratch 3.0 Opens New Doors For Users And Builders Alike

We typically feature projects from people sharing what they’ve learned while building something for themselves. But our community has a healthy contingent who deploy their skills for the benefit of future generations, developing a child’s natural curiosity for play into interest in understanding the technical world they will grow up in. This field is where MIT’s release of Scratch 3.0 can open up interesting possibilities.

Scratch is a block-based programming language designed for elementary school children, letting them learn fundamental concepts while experimenting in an environment filled with visual and audible feedback. In an effort to make Scratch more widely available, version 2.0 in 2013 moved to the web. But it was built using interactive web technology of the time: Adobe Flash. As Flash has fallen out of favor and scheduled to be phased out in 2020, Scratch 3.0 used React to make the shift to HTML5.

The most immediate benefit is that Scratch can now be used on tablets, which all have modern browsers but very few of which have Flash. Another common educational hardware platform is the Raspberry Pi, which supported Scratch 2 via a convoluted software stack that was far from ideal. Now any hardware with a modern browser can run Scratch, no Flash binaries or custom wrappers are required. The Raspberry Pi foundation certainly seemed excited about this change.

But a more exciting and longer term benefit is Scratch extensions, a mechanism for Scratch programs to communicate with external hardware and online resources. This has evolved in parallel with Scratch 2.0 under the experimental ScratchX umbrella and version 3.0 brings it into core. The launch featured a few official extensions (for connecting to micro:bit, LEGO Mindstroms EV3, etc.) with the promise that custom third-party extensions will soon be possible. This will significantly streamline building a Scratch interface for kid-friendly programmable hardware. Something we’ve seen done for a drone, for exploring SDR, and even for a dollhouse. We’ll be keeping an eye out for the official release of Scratch 3.0 custom extension API, but anyone not afraid of working with fluid pre-release code are certainly welcome to dive in right now.