Early in my exploration of robotics on the Arduino platform, I ran into a number of issues simultaneously that needed addressing before I could move forward like I wanted:
- The setup()/loop() model of programming was pretty simplistic. I was thinking in terms of multiple subsystems all doing their own thing and interacting, but the Arduino just gives you “do this, over and over”.
- loop() starts executing immediately; but especially with something like a robotics project you want a chance to disconnect the USB cable and put the robot on the floor before it gets started (or get to a safe distance, depending on your application).
- Sometimes you want to shut the robot down from a distance, when it gets out of control.
In my previous blog post I showed how to record then recognize an IR message from a remote control button press, and in this post I’m going to introduce the scheduling framework I am using, and show how to use the remote control to switch between a dormant ‘sleep mode’ (sits quietly while an LED blinks) and normal operating ‘awake’ mode when it otherwise follows it’s programming.
Humanity is safe as long as the blue LED is blinking
Follow me through the jump if you want to see how I did it. Or just check out the completed sketch [GitHub].
In this post I’m going to demonstrate code to record the pulse-width timings coming from an IR sensor and use that to record a button-press from a TV remote. Then I’ll turn that around and use it to identify that same button-press later on, using an interrupt to make sure your robot gets your command. If you’re a TL;DR sort of person, consult the ir_capture.ino sketch to capture the pattern for a given button, and the ir_identify.ino sketch to respond when that specific pattern is detected.
More after the jump, if you want the full story.
This is an ‘encore presentation’ of a post I originally wrote for my old blog — it was lost in the great blog fire of ’12 and (thank you Wayback Machine) is being edited and reposted here since it seemed to be pretty popular at the time. If you’re going to follow along with what I’ve done, give a quick look at Step 4 where I discover I’ve been using the wrong chip and have to change things up a bit.
The source code is hosted on Github here. There’s not really too much of it, but it’s worth making public for people.
I’ve long had an interest in experimental electronic music, so I’m excited that I have something to share in that arena.
In the past I’ve mentioned my wonderful wife (who is wonderful, if I didn’t say so), and for Christmas she doubly earned that distinction by buying me a Gakken SX-150 Analog Synthesizer. As far as a ‘kit’ goes, it isn’t much to speak of — just installing the pre-built board and speaker into the plastic case and wiring up the stylus controller — but it is such a simple design that it seems built to be hacked on, and that’s what I wanted to do.
I did find a number of cool SX-150 hacks, but often they were a bit more advanced than I’m ready for, so I figured I’d start with something simple and slowly build on it and make this a multi-part project. Since I’m really enjoying getting into Arduino programming, an Arduino-based sequencer seemed like a good candidate — so let’s get started!