A Slide Viewer Makes An Excellent Case For An OLED Project

Sometimes when browsing the websites of our global hackspace community you notice a project that’s attractive not necessarily because of what it does or its technology but because of its presentation. So it is with the subject of this article, [Kris] needed a house temperature monitor and found a 1960s slide viewer made an excellent choice for its housing.

The monitor itself is a fairly straightforward Arduino build using a couple of DS18B20 1-wire temperature sensors and a real-time-clock module and displaying their readings on a small OLED screen. Its code can be found on this mailing list thread if you are interested. The display presented a problem as it needed to be reasonably large, yet fairly dim so it could be read at night without being bright enough to interrupt sleep.

A variety of projection techniques were tried, involving lenses from a projection clock, a magnifying glass, and a Google Cardboard clone. Sadly none of these lenses had the required focal length. Eventually the slide viewer was chosen because it was pointed out that the OLED screen was about the same size as a photographic slide.

Slide viewers are part of the familiar ephemera of the analog era that most people over 60 may still have taking up drawer space somewhere but may well be completely alien to anyone under about 30. They were a magnification system packaged up into a console usually styled to look something like a small portable TV of the day, and different models had built-in battery lights, or collected ambient light with a mirror. The screen was usually a large rectangular lens about 100mm(4″) diagonal.

[Kris]’s Vistarama slide viewer came via eBay. It’s not the smallest of viewers, other models folded their light paths with mirrors, however the extra space meant that the Arduino fit easily. The OLED was placed where the slide would go, and its display appeared at just the right magnification and brightness. Job done, and looking rather stylish!

We’ve not featured a slide viewer before here at Hackaday, though we did recently feature a similar hack on an Ikea toy projector. We have however featured more than one digital conversion on a classic slide projector using LCD screens in place of the slide.

Via Robots and Dinosaurs makerspace, Sydney.

Arduino Meets Da Vinci In A Gesture-controlled Surgical Robot

Lots of us get to take home a little e-waste from work once in a while to feed our hacking habits. But some guys have all the luck and score the really good stuff, which is how these robotic surgical tools came to be gesture controlled.

The lucky and resourceful hacker in this case is one [Julien Schuermans], who managed to take home pieces of a multi-million dollar da Vinci Si surgical robot. Before anyone cries “larcency”, [Julien] appears to have come by the hardware legitimately – the wrist units of these robots are consumable parts costing about $2500 each, and are disposed of after 10 procedures. The video below makes it clear how they interface with the robot arm, and how [Julien] brought them to life in his shop. A quartet of Arduino-controlled servos engages drive pins on the wrist and rotates pulleys that move the cables that drive the instruments. A neat trick by itself, but when coupled with the Leap Motion controller, the instruments become gesture controlled. We’re very sure we’d prefer the surgeon’s hands on a physical controller, but the virtual control is surprisingly responsive and looks like a lot of fun.

When we talk about da Vinci around here, it’s usually in reference to 3D printers or a Renaissance-style cryptex build. Unsurprisingly, we haven’t featured many surgical robot hacks – maybe it’s time we started.

Continue reading “Arduino Meets Da Vinci In A Gesture-controlled Surgical Robot”

Hackaday Prize Entry: 8-Bit Arduino Audio For Squares

A stock Arduino isn’t really known for its hi-fi audio generating abilities. For “serious” audio like sample playback, people usually add a shield with hardware to do the heavy lifting. Short of that, many projects limit themselves to constant-volume square waves, which is musically uninspiring, but it’s easy.

[Connor]’s volume-control scheme for the Arduino bridges the gap. He starts off with the tone library that makes those boring square waves, and adds dynamic volume control. The difference is easy to hear: in nature almost no sounds start and end instantaneously. Hit a gong and it rings, all the while getting quieter. That’s what [Connor]’s code lets you do with your Arduino and very little extra work on your part.

Continue reading “Hackaday Prize Entry: 8-Bit Arduino Audio For Squares”

Quickie USB Keyboard Device

There are a ton of applications that we use that can benefit from keyboard shortcuts, and we use ’em religiously. Indeed, there are some tasks that we do so often that they warrant their own physical button. And the only thing cooler than custom keyboards are custom keyboards that you’ve made yourself.

Which brings us to [Dan]’s four-button Cherry MX USB keypad. It’s not really all that much more than four keyswitch footprints and an AVR ATmega32u4, but that plus some software is all you really need. He programs the Arduino bootloader into the chip, and then he’s using the Arduino Leonardo keyboard libraries. Bam! Check out the video below.

Continue reading “Quickie USB Keyboard Device”

Gcc: Some Assembly Required

There was a time when you pretty much had to be an assembly language programmer to work with embedded systems. Yes, there have always been high-level languages available, but it took improvements in tools and processors for that to make sense for anything but the simplest projects. Today, though, high-quality compilers are readily available for a lot of languages and even an inexpensive CPU is likely to outperform even desktop computers that many of us have used.

So assembly language is dead, right? Not exactly. There are several reasons people still want to use assembly. First, sometimes you need to get every clock cycle of performance out of a chip. It can be the case that a smart compiler will often produce better code than a person will write off the cuff. However, a smart person who is looking at performance can usually find a way to beat a compiler’s generated code. Besides, people can make value trades of speed versus space, for example, or pick entirely different algorithms. All a compiler can do is convert your code over as cleverly as possible.

Besides that, some people just like to program in assembly. Morse code, bows and arrows, and steam engines are all archaic, but there are still people who enjoy mastering them anyway. If you fall into that category, you might just want to write everything in assembly (and that’s fine). Most people, though, would prefer to work with something at a higher level and then slip into assembly just for that critical pieces. For example, a program might spend 5% of its time reading data, 5% of its time writing data, and 90% of the time crunching data. You probably don’t need to recreate the reading and writing parts. They won’t go to zero, after all, and so even if you could cut them in half (and you probably can’t) you get a 2.5% boost for each one. That 90% section is the big target.

The Profiler

Sometimes it is obvious what’s taking time in your programs. When it isn’t, you can actually turn on profiling. If you are running GCC under Linux, for example, you can use the -pg option to have GCC add profiling instrumentation to your code automatically. When you compile the code with -pg, it doesn’t appear to do anything different. You run your program as usual. However, the program will now silently write a file named gmon.out during execution. This file contains execution statistics you can display using gprof (see partial output below). The function b_fact takes up 65.9% of CPU time.

screenshot_232

If you don’t have a profiling option for your environment, you might have to resort to toggling I/O pins or writing to a serial port to get an idea of how long your code spends doing different functions. However you do it, though, it is important to figure it out so you don’t waste time optimizing code that doesn’t really affect overall performance (this is good advice, by the way, for any kind of optimization).

Assembly

If you start with a C or C++ program, one thing you can do is ask the compiler to output assembly language for you. With GCC, use a file name like test.s with the -o option and then use -S to force assembly language output. The output isn’t great, but it is readable. You can also use the -ahl option to get assembly code mixed with source code in comments, which is useful.

You can use this trick with most, if not all, versions of GCC. Of course, the output will be a lot different, depending. A 32-bit Linux compiler, a 64-bit Linux compiler, a Raspberry Pi compiler, and an Arduino compiler are all going to have very different output. Also, you can’t always figure out how the compiler mangles your code, so that is another problem.

If you find a function or section of code you want to rewrite, you can still use GCC and just stick the assembly language inline. Exactly how that works depends on what platform you use, but in general, GCC will send a string inside asm() or __asm__() to the system assembler. There are rules about how to interact with the rest of the C program, too. Here’s a simple example from the a GCC HOWTO document (from a PC program):

__asm__ ("movl %eax, %ebx\n\t"
"movl $56, %esi\n\t"
"movl %ecx, $label(%edx,%ebx,$4)\n\t"
"movb %ah, (%ebx)");

You can also use extended assembly that lets you use placeholders for parts of the C code. You can read more about that in the HOWTO document. If you prefer Arduino, there’s a document for that, too. If you are on ARM (like a Raspberry Pi) you might prefer to start with this document.

So?

You may never need to mix assembly language with C code. But if you do, it is good to know it is possible and maybe not even too difficult. You do need to find what parts of your program can benefit from the effort. Even if you aren’t using GCC, there is probably a way to mix assembly and your language, you just have to learn how. You also have to learn the particulars of your platform.

On the other hand, what if you want to write an entire program in assembly? That’s even more platform-specific, but we’ll look at that next time.

Control The Real World With An Arduino-Enabled Minecraft Mod

Minecraft modding has become almost as popular as the block-based game itself, with tons of editors and tools available to create new kinds of blocks, mobs, and weapons. And now, with this mod framework that can talk to an Arduino, modders can build blocks that break out of the Minecraft world to control the real world.

While turning on a light from Minecraft is not exactly new, the way that MCreator for Arduino goes about it is pretty neat. MCreator is a no-code framework for building Minecraft mods, which allows modders to build new game capabilities with a drag and drop interface. The MCreator Arduino toolkit allows modders to build custom Minecraft blocks that can respond to in-game events and communicate with an Arduino over USB. Whatever an Arduino can do – light an LED, sense a button press – can be brought into the game. It’s all open-source and free for non-commercial use, which is perfect for the upcoming STEM-based summer camp season. We can think of some great projects that would really jazz up young hackers when presented through a Minecraft interface.

Continue reading “Control The Real World With An Arduino-Enabled Minecraft Mod”

Morse Code: Paris In The Mint Box

TinyLilyThumbnail[Rob Bailey] likes to build things and he likes ham radio. We are guessing he likes mints too since he’s been known to jam things into Altoids tins. He had been thinking about building a code practice oscillator in a Altoids Smalls tin, but wasn’t sure he could squeeze an Arduino Pro Mini in there too. Then he found the TinyLily Mini. The rest is history, as they say, and 1CPO was born.

The TinyLily Mini is a circular-shaped Arduino (see right) about the size of a US dime. most of the pads are arranged around the circle and there is a small header that takes a USB programmer. A small rechargeable battery can run the device for a long time.

Continue reading “Morse Code: Paris In The Mint Box”