Based on the examples provided by Brainy Bits, we started with controlling the motors with an analog joystick. These are really cool devices that work nicely with any microcontrollers (PIC, Arduino, Propeller, Pi, whatever).
The added bonus? The Geek Mom automated Etch-A-Sketch project already included excellent code for “normalizing” the joystick input. If you are using one of these joysticks with Arduino, get her code. What it does is translates the X/Y into values from -1 to +1. And ignores random centered values. No more converting from 0-1023 (Arduino analog values). No more complicated code. She has figured that out already. Did I say I liked her code? Well, I love it.
For a while I had the scope moving around happily with the joystick. And, it’s pretty awesome to see the scope move around using this little thumbstick.
But — now I needed to add features. Like entering coordinates. Like starting and stopping. Like taking photos. Buttons. And guess what? With the “old school” stepper controllers I need 4 I/O pins per motor — so just X and Y take 8. Want to automate focus? That’s another four. And the joystick takes X/Y/Button just on it’s own.
And so it was time to say goodbye to the joystick.
Fortunately, I remembered that I had purchased a cheap IR remote and Receiver from Adafruit — about 5 years ago. I never got to that project, but look at the remote — it has exactly what I needed:
And, the best part, I could get all those commands through just one data pin! So, goodbye lovely joystick, hello IR remote.
Of course, there are a ton of IR libraries out there. There are the ones written by Limor Fried (Lady Ada), there are super powerful one written by Ken Shirriff. But, guess what happened?
Memory happened. As I add libraries, the memory constraints on the Arduino Nano became tighter and tighter. Ken’s library did everything I needed — and more — but was pushing my memory limits (remember: I still need to support a display, and maybe internet connectivity).
An aside: This is one of the reasons why I love working with microcontrollers — they limit you. In current development tools, you just throw more servers at a problem. What used to be solved with a 2K program is now in a 2Gb deployment package. And that’s crazy. It allows you to be sloppy, instead of really thinking through a solution. We landed men on the moon with less computing power than your pocket calculator (which has been replaced with a super computer — i.e. your telephone).
And so I searched and found a slimmed down version of Ken’s IR library. In a nutshell, it removes all the transmit code (which I don’t need) and the remote-specific code (ex. Sony, Panasonic, Sanyo, etc). I didn’t need that code since I have a no-name remote and had to map everything manually anyway.
So more trial and error, cleaning up code, and I was able to control our scope with an IR remote (one data pin!). And can now handle things like direct coordinate entry, automatic homing, and more. And if my IR remote doesn’t have enough buttons? I find one with more.