1.7 Writing, Wiring, and Testing
Unfortunately, no good software emulator exists yet for the Arduino; fortunately, programs for this platform are usually small and specific enough such that the compile-run-debug cycles are tolerable. Good coding and testing techniques go a long way toward ensuring a high-quality outcome. The same goes for constructing and wiring up the physical electrical connections.
While nearly all of the projects in this book can be constructed without solder, permanent installations require good soldering techniques to ensure a conductive pathway. It’s best to verify (usually with the help of a breadboard) that the connections work as expected before making them permanent with solder.
Use good code-testing techniques. Whether for microcontroller code for the Arduino or server-side code for your Ruby or Python scripts, Test-Driven Development (TDD) is a good practice to adopt. There are a number of good testing frameworks and books available on the subject. Read Ian Dees’s article, “Testing Arduino Code,” in the April 2011 edition of PragPub magazine,[11] as well as Continuous Testing: with Ruby, Rails, and JavaScript [RC11].
Run unit tests like py.test when writing Python-powered scripts. When coding in Ruby and creating Rails-based web front ends, consider using Rspec (for more details on using Rspec, read The RSpec Book [CADH09]). Use the Android testing framework for your Android applications.[12] Even when working on small applications, using proven testing methodologies will help keep you sane while further elevating the quality in your code.
Know how to use a multimeter. Like a software debugger, a multimeter can come in quite handy when trying to figure out what’s happening inside your project—for example, where a short might be stepping on your project. Besides detecting problems, a multimeter is also useful for measuring electrical output. For example, you can also use it to determine if a solar battery pack can deliver enough uninterrupted energy to power a microcontroller-operated servo.
If you’re not familiar with how a multimeter operates, just type “voltmeter tutorial video” in your favorite search engine. There are plenty online to choose from.