While this course of tutorials concentrates on the software side of Arduino work, inevitably, substantial information is also provided on hardware issues.
This page, and the software it references, ©TK Boyd, 1/2010.
Winking two LEDs: a first exercise. This is, of course, the "Hello World" of microcontroller programming. Your Arduino probably came programmed to wink one LED, just as a quick "Is it working?" test. The material in this tutorial is not rocket science, but please read through it anyway. It covers some important foundation material.
A better program.... to wink two LEDs! What is a "good" program?
A few general points. In this short tutorial I mention a few "gotchas".
Simple Counting on LEDs
Using the built in analog to digital converter.. .with, as always, general points illustrated along the way.
Two little discourses: Syntax is everything. Becoming a good programmer.
A BIG tutorial: This tutorial is big... sorry. It's just that one thing kept leading on to another. In it you can learn...
Sorry the tutorial is so big, but it covers important ground. Along the way, we will make a pretty little LED flasher. The rate the lights flash is changed by turning a potentiometer. ("Volume control", variable resistor.)
If you only want a quick "How To" about connecting an LCD panel, there is a page for you about just that.
Using switches to send input to the Arduino: At last! This tutorial opens the door to all sorts of things. It is the first of two about reading switches. It discusses the electronics in addition to the usual help with the programming issues.
A second tutorial about sending input to the Arduino using switches: This tutorial extends the previous one. It also introduces the Boolean data type, Boolean variables, and Boolean operators.
Functions that return values: We've met functions, but not functions that send a value back to where the function was called. Functions which return values are incredibly useful. This tutorial also discusses aspects of Arduino arithmetic, including the modulo function.
Using what we've done: There's not a lot of new "words" in this... but in it we put to use some of the things learned in earlier tutorials. We create a device to count two different events. "Switch bounce" gets further consideration, too. (Car overtaking counter example.)
FROM serial monitor TO Arduino: Earlier we saw how messages could be passed from the Arduino to the IDE's serial monitor. This tutorial shows you how to send things the other direction.
A flashing LED toy: You can skip this one without missing the introduction of new concepts. However it is short, and yields a little "toy" which I hope is fun. It flashes its LEDs at a variable rate, which is altered by changing the setting on a potentiometer. The tutorial also tries to explain bottom up development.
Up/ Down counter. Switch bounce. Binary numbers: You are finally getting rewards for your earlier work. This tutorial won't be very taxing, it draws on things you know. It looks again at "switch bounce" (and does a better job than the first review of that topic!) And discusses things many students find puzzling about showing numbers in binary.
Compound Operators: A brief discussion of an optional shorthand you may find useful. You may want to use it yourself, and you may need to be able to read it to understand what other people's programs are doing.
Comparison Operators: The various tests available to Arduino programmers when asking if something is true or false, e.g. "if (bTmp>5)...".
The tutorials above cover many aspects of the language used for programming the Arduino. Of course, if you had an English dictionary and guide to English grammar and syntax, it wouldn't mean you were ready to write Hamlet. Using the Arduino language is a fascinating adventure that is never-ending. I hope you will find time and have the "knack" to enjoy it. If you have tried and tried to get started, and it just seems to be getting worse and worse... you are probably on the verge of the "breakthrough" that many programmers remember making. It will get easier!
After writing the tutorials above, I set about a larger project, illustrating the use of some of the things explored in the tutorials, and showing you the development process applied to a non-trivial design requirement. (The "design requirements" of all the programs in the tutorials are pretty limited, after all.)
The Grand Finale: Access Control. The Grand Finale, takes you to a page consisting of little more than a well documented (internally) Arduino "sketch", or program, for a access control device (electronic lock) made up of....
(The strikeplate can be simulated with an LED if you wish.)
The device presents a "challenge" in the form of a randomly chosen pattern of ons and offs on the two LEDs. If a user enters the right response, by pressing one or both of the buttons, the electro-mechanical strike plate is activated for a pre-set interval, and the user can open a door which was previously locked.
On this page, you get the full sourcecode, with extensive in-line documentation. There may be some "errors" arising from issues of the "typesetting" of the Arduino code into HTML. (For example, where >s appear in the Arduino code, they had to be altered to something else to make them appear as you see the example in this paragraph.)
The whole story of the development of the Access Control Device (final result given in previous paragraph/ web page) is told in the sum of the following three pages. They are still very rough, with typos and spelling mistakes... but the underlying code is sound, having been copy/pasted from the Arduino IDE as the project progressed. There may be some "errors" arising from issues of the "typesetting" of the Arduino code into HTML. (For example, where >s appear in the Arduino code, they had to be altered to something else to make them appear as you see the example in this paragraph.)
Access Control Device story... First Part, and problem specification.
Access Control Device story... Second Part.
Access Control Device story... Third and final part.
The globe on the right helps me see if doing these pages is worth the time it takes. It is interactive; play with it, if you wish. (You need to use your browser's "back" button to get back here after doing so.) The only information the system records is when visitors access the site, and where their ISP connected them to the internet. (In my case, that is 60 miles from where I live, at the moment.)
This comes to me as a free service from Revolvermaps.com. If you know how to insert HTML into your own web pages, it is easily added.
What's Left? The page this link takes you to tells you what is NOT covered in the tutorials. It may have false positives... but you can use the search tool below to check.
See the discussion on the "top level" page covering the bulk of my Arduino contributions. There is information there, too, about things like "May I copy your material?", and the system of file names I am trying to work to.
The seven links below take you to scraps of an earlier set of tutorials for the Arduino. Some of the material in some of them... especially the last two... may be worth your time... but first read at least the first few of the new tutorials (top of this page)?
1) Start Here: Setting up. And some general points.
2) Second tutorial: Going loopy.
3) Third tutorial: Introducing variables.
4) "3c" Getting output during development, e.g. messages to help with debugging.
5) "3b" Surviving with or without an LCD display. **You reallydo not need to do this one.** (It was borderline before the set of tutorials it was part of was superceded. Left online for the very curious!) But do consider the next two...
The next two are more likely to reward time spent studying them. They aren't coordinated with the modern course, but still may contain useful and unduplicated elements.
6) Fourth tutorial More on variables.
7) Fourth tutorial- alternate version Very like the previous, but with a more elegant program.
The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.
SPELL your search term properly. When I review search logs, it is amazing how many people ask the engine to search for something meaningless.
Why does this site cause a script to run? I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try it, check out their site. And if there are Google ads on the page, they are run with scripts, too.
Here is how you can contact this page's editor. This page, and the software it references, ©TK Boyd, 1/2010.
Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes.