Introduction

(Stephen Leacock) “Writing is not hard. Just get paper and pencil, sit down, and write as it occurs to you. The writing is easy—it’s the occurring that’s hard.”

I think microcontrollers can be a bit like that. You have a world of possibility—a blank page if you will—and you can combine the intelligence of your MCU, your own imagination, and the fantastic toolkits you have at your disposal to build pretty much whatever you can imagine. But, what will you build?

For some people, amassing the tools and the parts to build MCU projects can turn out to be most of the fun. Like a “wannabe” chef who spends ages sharpening knives, polishing silverware, and finding neat and tidy places for every little implement, it’s easy to get mesmerized by the tools and the processes and lose sight of what it’s all for. For other people it’s the other way around: they have a plethora of ideas, but no clear idea how to break the overall task down into manageable steps to make it happen.

Here, our focus is definitely on the “what.” - as in “What can I build with all these great tools and techniques?”. We’re going to run through a number of projects, small ones and not so small ones. My hope is that, even if you don’t want to build these projects they will help you create ideas of your own. I also hope you’ll gain a few perspectives on the different activities concerned with MCU projects and their possible sequencing. Another possible side effect may be that you’ll start to see the contents of your plastics and cardboard recycling bin in a whole new way!.

Project Bases

In most projects in this book you have a simple choice about what base to build upon. The choices are one of the following:

  • Building the project on a breadboard with an attached AVR programmer.
  • Building the project on a piece of solder board of some kind (see the “Duck Shooter” game for an example of doing it this way).
  • Using a freeware package like Eagle or Fritzing to design a printed circuit board for the project and building your version of the project onto that. Of course, this can be quite an expensive option, although the software mentioned is free (and there are other free software packages, too), when you use them to design a PCB you still have to pay someone to make your circuit board from the design that is produced by the package.

Deciding which project to build in which way is going to be largely determined by whether you regard the project in question as a “keeper” project. In other words, do you plan to build up the project, get it working, stand back in awe of its wondrousness for a while, and then tear it down and reuse the components for something new? Or, do you plan to deploy the project to your home, your office, or your car as a permanent fixture? If the former, then you’ll want to build the project on a breadboard. If the latter, then you’ll want to build your project on something that you can build into a box and have it become a piece of “set and forget” infrastructure in your home or office.

Whatever method you use it’s very important that you include the all-important ISP connector for updating the MCU software so that you can make changes to the software as needed. You want to avoid a situation where you use a stand-alone programmer and have to keep moving the MCU chip between project and programmer. So, it’s your decision as to what base you use for the electronics side of the projects. The circuit diagrams mostly assume you’ll be building a custom board, so if you’re building on a breadboard you’ll need to do some small amount of adapatations around power supply arrangements.

Project Chapter Formats

In general, the format of each project chapter is

  • A description of the project: what it does, why you might want to build it.
  • A design discussion, detailing the trade-offs and features of the design.
  • A “maker” section, which deals with how to make any mechanical elements of the project and some pointers to where you might find the parts you need.
  • A circuit diagram for the electronic aspects of the project (including the MCU).
  • Details of the project software. In most cases the software is too long to reproduce in full, so there is a summary of the software and the full software listing is available for download.
  • A code walk of the software that names all the software’s functions and provides a short commentary about what each one does. This code walk is intended to help you understand the full software listing when you download it from the book’s web site (http://www.apress.com/9781430244462).

Each project is illustrated with diagrams and photos that should help you build one of your own or more likely, make your own version of it. Even if you start by building the project as presented here, you’ll learn a lot more from modifying it later on to meet your own needs. In many cases you’ll probably make improvements or enhancements to my original design in the process of customization.

A quick word on legibility … the difficulty of legibly reproducing circuit diagrams with lots of fine detail in a printed form is something that authors and publishers have always struggled with. Fortunately, the Internet makes it possible to offer you an alternative. If there is detail in a circuit diagram that you can’t make out in this book, go to the book’s web site where you will find electronic versions of all the diagrams in formats that will enable you to enlarge details that may be hard to see on the page. As mentioned previously, the full software listings are available on the web site too.

All the circuit diagrams have been reproduced here from my original completed designs, so they should work for you just as well as they did for me. However, if you find any mistakes please let me know via the publisher, so that we can verify the error and put corrections on the web site to help other people. Similarly, if any components or parts used in the projects should become unavailable between the writing of this book and when you need them, we will put information on the web site about possible workarounds or replacement products that may serve the same purpose.

Whilst working with electronics, be aware of static electricity. Get yourself an anti-static work mat and wrist band if you can. Think about this. You’ll have had a static shock yourself at some stage, perhaps from a car door, from a door handle, or from touching some piece of earthed equipment. So you, at whatever size you are, can get static electricity shocks from things. But in fact, you get static shocks all day every day from many things; it’s just that most of them are much too small to register with your nervous system. But now, reflect that you are handling chips that have millions of transistors inside them, many of which are less than one millionth of an inch across. On that scale, the tiny shocks that you don’t even notice seem like lightning bolts to those tiny components and can destroy or weaken them in an instant.

Of course, most modern semiconductors have a certain degree of inbuilt static protection on their external pin connections, but we need to help things along by being aware that we bring static electricity to the work bench with us and generate more while we’re working. So, using an anti-static kit is a good habit to get into. Don’t get paranoid about static, but don’t pretend it doesn’t exist: You may not zap your semiconductors outright, but a lack of static control can shorten their life span and/or make them operate unreliably.

Finally, please work safely. You are dealing with electricity in these projects and electricity should always be treated with respect; even if you are only dealing with 5 volts, respect and care should be the watchwords. Ensure that your power supply is a safe one. It should be appropriately fused on the mains side and on the DC output side. Inappropriate fuse values are a major safety hazard. Fitting a 10 amp fuse to a device that only ever uses 1 amp is crazy and potentially dangerous: if a fault occurs in the device then it could heat up nicely and even catch fire before it blows the fuse. Try to fuse your devices at no more than what they need plus perhaps 10% extra. Appropriate AC-side fusing should ensure that, should anything go wrong, you’ll have a dead device on your hands, not a house fire. Appropriate DC-side fusing might make the difference between having to replace the fuse and having to replace a whole board full of components.

When you are soldering, wear goggles if you can, to protect your eyes from the smoke. Always make sure your work area is well ventilated so that you don’t have to breathe in the solder fumes and smoke; use a desk fan set on low to waft smoke away toward an open window. Use a soldering iron that has some kind of holster or holder so that you don’t burn holes in your carpets, furniture, clothes or yourself! Never, ever flick solder around; it stays hot for a long time after it leaves the iron. If you need to remove solder from the iron, use a damp (but not wet) ball of tissue paper or scrap cotton material.

If you need to remove solder from your project board (e.g., because you put a little too much on and it has bridged two contacts when you didn’t mean for that to happen), get yourself a solder sucker. These are quite cheap to buy, and provide a manually operated suction pump with a heat-resistant tip that can be used to suck molten solder away from a board.

So, work safe, use a helping-hands project gripper if you have one and be sensible and very careful about soldering iron usage.

Project Scope and Difficulty

The projects are presented in no particular order. Some of the projects are large and some are small. They’re also of various types—some are purely electronic, but many include some degree of “makery”—using easy-to-get materials (such as stick wood) or adapting or reusing stuff such as discarded plastic packaging or materials.

So, if you have a preference for starting with, say, a simple project, choose one that you can build up on a breadboard. If you’re inclined to build something that has more of a mechanical element to it, you’ll probably want to start with a project like the sliding panel, which is heavier on construction and not so heavy on electronics.

The simple fact is that the only thing that the projects truly have in common is that there is an AVR embedded in each and every one. But, that’s why we’re here! I hope you build at least one of the projects, or at least that you enjoy reading about them all.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.135.175