3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Reading Switches with ATtiny2313

Step 4More Debugging

There are many times when we want to check a section of code by skipping most of the lines in it, then enabling them one at a time as we verify each one works. Typically, we do this by "commenting out"lines we want to skip. An extension of this technique is to cut and paste a block of code, comment out the original (so we don't lose it), and hack away at the copy.

C has four easy ways to comment out lines.
Putting "//"in front of a line comments out that line.
Enclosing one or more lines in "/*"and "*/"will comment out an entire section. For this method to work effectively, there must be no other "*/" in the code block (other than the ending one). So an effective discipline is to use // for comments within blocks of code, and reserve the /* */ construct for comment blocks and for commenting out sections of code.
Placing "#if 0" at the start of a block to comment out and ending the section with "#endif".
More selective control is possible using "#ifdef (identifier)" at the start of a block and "#endif" at the end. If you want the block to be compiled, use "#define (identifier)" earlier in the program. Note the quote marks are for emphasis only and are not to be included.

Combining these techniques should provide a useful approach to debugging your ATtiny2313 programs. You may find these tools useful as we proceed through this Instructable.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
41
Followers
8
Author:doctek