Prototyping an Interactive Experience

Just another WordPress.com weblog

Debugging Circuits and Code

leave a comment »

In dealing with interactive stuff whether it is hardware based or software based, one of the most important skills is debugging.

In most cases when you are starting out with this stuff, it will rarely be a simple as plugging things in and it magically works.  So you’re going to need to figure out why something is not working. 

Part of the art of debugging is taking is learning to build your project in little pieces and to try to everything working all at once.   When I first started out with this stuff, I would spend hours putting something together, and then try to turn it on.  Then I would spend another set of hours just to get things to turn on, let on work like I thought it should. 

The trick is to divided your project in to little pieces, make sure that each piece is working before moving on to the next piece.  

For example when building your LED light, start by getting the simplest thing to work first
-Get an accurate range of values from your sensor, map out the range of values that your going to use for your interaction.
- Then build in the logic.  Start by using simple condition statements to get your light to respond to the sensor
- Create a small program that animates light 
- Combine the sensor code with animation code

Chances are very good that you still have to spend some time debugging your application, so we began by asking a set of questions:

1. Is it plugged in? Does it have power? 

Most Boards that you get will have a status LED that shows you that it is getting power. 

2. Is the cable connected properly? 

Sometimes when you’re programming something you’ll get errors where the chip is not responding for some reason, this could be due to your programming cable not being properly connected.  

3. Is a wire loose?

When you’re breadboarding stuff it’s very easy to make a mistake in wiring.  You cut a wire too long or too short, and it’s popping out of the socket. Part of the trick is to do a proper job in the first place, then the second part is to be good at spotting problems with your own design.  Use a multimeter to check for line continuity and proper voltage levels.

4. Is a wire short circuiting?

This is a problem that can be obvious or not so obvious based on it’s severity

If it’s severe you’re little project will be giving off heat, and smoking. This means that you wired something up backwards, or a wire is crossing another wire somewhere. 

5. Is the problem with my code?

Here is where you start using Serial.print statements to make sure you’re program is behaving like it should. Check to see if the sensor is giving you the right range of values.  Use Serial.print statements in your condition statements to see if your logic is sound.

6. Is my hardware defective?

This should be your very last conclusion.  Nine times out of ten, you’re the one that has made the mistake, not someone else.

So you move though your design piece by piece, until you find out what the problem is.  With the stuff that we’re doing, it’s easy to create problems that are both software and hardware related.  Remember,  take your time work slowly, comment your code, and keep your wiring neat, and you’ll get good at spotting your errors.

Written by tankstar

September 23, 2008 at 9:25 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.