Maker of all trades, Chuck Stephens, shares his insights on learning to love the Arduino.
I have an admission to make- I was an Arduino resistor. It’s not that I didn’t appreciate what could be done with microcontrollers; I saw many awesome projects at maker fairs and online that proved the Arduino was more than a toy. Part of my disdain was because I wanted to design circuits, not write programs. Arduino and similar microcontrollers seemed like cheating. To really understand what was going on, I reasoned, you would need to build physical circuits. Also the process of learning a programming language seemed daunting to someone who’s last programming experience was writing BASIC 25 years ago. Finally, I was somewhat of an analog purist. My main interest is in synthesizers and sound devices. I thought that analog synths were the best way to get the sounds I wanted and that digital sound synthesis was not nearly as versatile.
Well boy, was I wrong!
An Expensive Way to Blink an LED
We’ve all seen it- Someone posts a project that uses a $30 microcontroller to do something that I could do with a couple of dollars worth of components. What a cheater! I’ve spent the last four years learning electronics and breathing solder fumes while this guy just waltzes in here and makes an LED blink like he’s Tesla or something. He probably doesn’t even know who Forrest Mims is. What nerve!
Of course this kind of thinking assumes that the person using the Arduino to do something simple is interested in learning electronics in the first place. Maybe they’re an artist who just wants to add some simple interactivity to a sculpture without having to earn an electrical engineering degree. Maybe they’re a programmer wanting to add some peripheral input to a bit of code they’re writing. Maybe they just want a blinky LED and this was the easiest way to get it. Ultimately, who cares?
While microcontrollers do make electronics more accessible to noobs and folks outside the field, that’s hardly the point for experienced users. The important thing about microcontrollers is the incredible power and versatility they offer the active hobbyist and inventor. In the hands of someone with a good grasp of electronics, the Arduino can save a lot of time and space and get you from the design phase to a working prototype very quickly. Just because you can build a circuit from components doesn’t mean you have to. What do you have to prove? Victory comes from a successful project, not the number of steps involved.
Root, Hog, or Die!
I was required to take two years of a foreign language in high school and, being very stubborn, I refused to take Spanish and opted for French instead. The fact that I had no one to practice with besides my classmates meant that very little of what I ‘learned’ was actually retained. Years later I visited Paris, and within days I was amazed by how much of my French came back. While I was far from fluent, I could ask directions, make purchases and order food with ease. The key was to be totally immersed in the language. It’s amazing how easily you learn when you have no other choice. As they used to say in the south when they turned the pigs out to forage- root, hog, or die!
Learning a computer language seems quite a bit harder then learning my broken tourist French. At least a foreign language will have recognizable syntax and grammar. Even if you don’t understand the words, you will have some understanding of how they go together. When I looked at some Arduino code nothing was familiar at all. It looked alien. I checked out some tutorials and the code samples they used seemed just as confusing. My Arduino sat on the shelf for months while I thought about ‘setting aside some time’ to learn how to use it.
Fast forward to the recent Make/Intel Galileo Hacks Session on Google Hangouts. The folks at Make sent me a nice package with an Arduino starter kit, an Intel Galileo microcontroller board and a few more goodies. We were given three weeks to develop a project and present it in an online hangout. Usually when I participate in these kinds of programs I do the physical build and have a partner do the programming. I started building a prototype of a 4 axis laser spirograph confident that the programming would be taken care of. As the last week of the session got closer and other responsibilities piled up I began to panic- There was little time to try to schedule a session with a programmer before the big show and tell.
With the final hangout scheduled for Thursday night, I woke up on Saturday morning determined to do something. I had no choice- I was under the gun and I could not fail. I would cram and buckle down and try to learn some basic functionality to turn into a project for Thursday evening. I opened Lady Ada’s tutorial and resigned myself to the task at hand. I had no one to rely on but myself, so I plugged the Arduino into the computer, opened the IDE and loaded the Blink sketch. I realized that each step of the program was explained in plain English throughout the sketch. Maybe this wasn’t quite as bad as I’d imagined…
Success! The LED was blinking.
I followed Adafruit’s tutorial and determined what the variables were. I tried shorter blinks with longer gaps and long flashes that blinked off and back on quickly. I copied the main part of the sketch and pasted it onto the end to make a long flash followed by a short flash, over and over again. I added a new sketch that allowed me to control the speed of the flashes with a potentiometer. I doubled the sketch and changed the pin assignment and was able to control two separate LEDs.
I felt kind of foolish. This was easy! Why haven’t I been doing this for years? I soon realized that learning to use the Arduino wasn’t like learning an entire new language at all- it was more like being a tourist learning some key phrases and how to combine them. By using them they began to make sense and I spent the rest of the day adding new phrases and seeing how they worked together.
I needed to assemble a motor shield that plugged into the Arduino and allowed me to control multiple motors or servos simultaneously. This meant downloading a new library. The library contains new commands and code for accomplishing specific tasks as well as examples of how to use these new commands. I found an example sketch that read the value of a potentiometer and used it to control the speed of a motor. This formed the backbone of my project’s code.
The great thing about the Arduino IDE is that it comes with its own built-in phrase book. By opening examples in the file menu of the IDE you will find a selection of very basic sketches with plain English explanations. You can alter and combine these small bits of code to create a more complex sketch quite easily. By Tuesday evening I had a sketch capable of using four potentiometers to precisely control the speed of four motors with mirrors mounted on them slightly off center. By bouncing a small laser pointer between the four spinning mirrors and onto a wall you get complex swirling patterns and shapes. Since I still had two days until the show and tell and I love noisy projects, I decided to add another bit of code to create sweeping sounds to go with the light show. I used the input from the pots to control the pitch and other parameters of the sound from a speaker so the light and sound would sync up.
One problem I ran into was that the Galileo, being new, wouldn’t recognize several of the libraries that I needed to make my project to do what I wanted. The project ran perfectly with the Arduino but the Galileo just would not work. Since the Galileo was the focus of the hack session, I was determined to incorporate it in some way. The Arduino has six analog pins which are perfect for reading variable voltages from a potentiometer. The motor shield uses two of the analog pins to communicate with the Arduino, so after connecting the four speed/sound control pots, all of my analog pins were used. I decided that having the laser blink at a variable rate would add another facet to the potential patterns created by my projector. I loaded the basic blinking LED sketch onto the Galileo with a pot on one of the analog pins and the power to the laser connected to one of the digital pins. Yep- I used Intel’s feature-packed new microcontroller to blink a single LED.
Don’t you hate it when someone uses a $70 microcontroller to do something that you could easily do with a couple of dollars worth of components? What a cheater! What nerve!
When Thusday rolled around I was given a few minutes to explain my project and demonstrate it during the hangout. I was amazed that I had gone from a basic blinking LED to an impressive and interactive project in less than a week. My mistake was trying to understand the Arduino before I actually plugged it in. That’s like trying to learn to swim by reading a description of swimming. The only way to learn how to use the Arduino is to plug it in and follow the tutorials. Go step by step and it will all make sense. All of my assumptions about learning to use the Arduino IDE were wrong. Much like on my Paris trip, when I immersed myself in the language it quickly began to make sense.
Confessions of a Hipster Music Snob
I grew up with a fascination for electronic music. From the fat synthesizer bass lines of disco and early hiphop to the futuristic sounds of new wave, keyboards, sequencers and drum machines offered an exciting musical palette. For me, the ideal electronic instrument is designed to create unique new sounds rather than simulate other instruments. Since most digital keyboards were loaded with samples designed to recreate existing instruments they tend to sound fake and inauthentic. Analog instruments, on the other hand, can produce a wide variety of sounds, from familiar organ and horn sounds to far out sound effects and noises with no real-world comparison. Analog synthesizers and drum machines are coveted by music producers for their warmth and versatility.
This preference is one of the main reasons I wasn’t in a hurry to experiment with the Arduino. While it might be great for controlling a robot or other mechanical device, I didn’t have high hopes for the board’s musical potential. When I loaded the basic synthesizer code into the projector it created interesting sounds but a grounding problem caused motor noise to bleed through. Since I had another Arduino, I decided to build a stand alone synthesizer. I used a sketch called Auduino that used five pots to control the filter and cutoff of a stepped tone synthesizer. The pitch was controlled by a pot and was divided into steps in the key of E major. Turning the knob automatically created a musical scale, from deep, throbbing basses to piercing clear high notes. By controlling the pitch with one hand and the filter and cutoff with the other you can create very impressive and dynamic sounds with a unit that costs less than $50.
Chuck and his sound machines at Gulf Coast MakerCon 2014
The real test came when I got to demo the synth for my friend who is a vinyl DJ and analog synth player. He hates digital gear even more than I do and I knew he would be a tough critic. I started off with some clean mid-range melodies and rhythms. I adjusted the cutoff and raised the pitch for some gritty brassy leads and my buddy seemed to be enjoying it. Then I went for the jugular and dropped the pitch down way low while tweaking the filter for some funky bass lines and dubstep-style filter wobbles. When I stopped he was quite impressed and asked what circuit I used. I just grinned, opened the enclosure and showed him the Arduino.
So much for hating digital synths.
Hallelujah! I’ve Seen the Light
So now I’m an Arduino convert. Microcontrollers are another useful tool for making the things I make. While the Arduino and other boards are very useful, to get the most out of them you need a general knowledge of electronics. You could choose to learn circuit design first and then move on to microcontrollers or you can start out with an Arduino and a handful of components and learn the electronics as you go. The important part is that you are learning and creating. Learning what you need when you need it is what ‘making’ is all about.
I no longer see the Arduino as cheating but as a way to do complex projects quickly and with a small footprint. I also found that the language is easy to get started with and the only thing standing in the way of getting started is actually getting started. The most important thing I learned about the Arduino is that it’s a flexible platform for building sensor projects, robots, interactive devices and even, gasp, musical projects. The only real limitations are the specs of your particular board and your imagination.