Arduino intro - adam-p/pubwiki GitHub Wiki

First of all

Don't panic. You won't understand everything at first, and that's good. Just glean what you can as you go along, look stuff up (Google, Wikipedia, etc.) if needed, and as me stuff if you get stuck. You'll pick up a surprising amount of knowledge as you go, and fill in the blanks as you need to.

And then you'll be making rad electronics that interact with the world.

Drivers and software

Jozef, you're going to need to install these couple of things that I set up for you dad last night:
USB/COM driver for the Redboard: http://www.ftdichip.com/Drivers/VCP.htm
Arduino IDE (I recommend the 1.5.5 Beta version): http://arduino.cc/en/Main/Software

("IDE": Integrated development environment. It's the application where you write your logic and load it into the board.)

Your dad's board (and so almost certainly yours) seemed to have a blink program loaded on it, so you'll probably see your blue LED blinking when you give the board power (i.e., plug in the USB cable). Sam: We cleared the blink (okay, flash) program, but then we loaded it again, so you're in the same boat.

To reassure ourselves that our boards are functional, let's stop the blinking by loading a blank sketch.

("Sketch": In Arduino parlance, the "logic" or "program" that runs on the board.)

Uploading a sketch

Determining which COM port the board is connected to

This is the only unfortunate and esoteric step. You need to manually tell the IDE which "serial port" (gibberish) the Arduino board is connected to, so you need to figure it out first.

  1. Run Device Manager. Click the Windows Start button and type "Device Manager". Then click it.

  2. Expand the "Ports (COM & LPT)" section. Under that you'll see something like "Arduino Uno (COM3)".

  3. Make note of the "COM3" (or whatever number you see).

    Find the serial port

(I have a Leonardo rather than an Uno, so my screenshots will say that.)

Upload sketch from IDE to board

  1. Run the Arduino IDE (probably just click the Start button and start typing "Arduino").

  2. The program that opens first is the basic, doesn't-do-anything-yet program. It looks like this:

    void setup() {
      // put your setup code here, to run once:
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly: 
     
    }
    
  3. On the "Tools" menu, go to the "Board" sub-menu and make sure "Arduino Uno" has a checkbox beside it.

  4. Also on the "Tools" menu, go to the "Port" submenu and select the serial port that you found above ("COM3" or whatever).

  5. Click the "Upload" button (the arrow pointing right) to send the sketch to the board. (The command is also on the "File" menu.)

  6. Wait a few seconds for the sketch to be sent to the board.

Then the light will have stopped blinking. Here's a screenshot of those steps:

Upload blank sketch

Bonus: Load the blink sketch back onto the board

I find it... reassuring(?) to have the board actually doing something, so let's put the blink sketch back on.

  1. Click on the "File" menu, then "Examples" submenu, then "01.Basics" sub-submenu, then "Blink". A new IDE window will open with this example sketch.

  2. Extra bonus: At the bottom of this sketch there are four lines of code. They do this:

    1. Turn the LED on.
    2. Wait for 1 second (1000 milliseconds).
    3. Turn the LED off.
    4. Wait for 1 second.

    Change the two instances of 1000 to 2000 (or only change one of them, or change them to whatever you want), so we can see a difference from before.

  3. Click the "Upload" button.

A screenshot of those steps:

Upload blink sketch

Resources

The place I bought your kits -- and a great place to get more bits and bobs -- is Creatron, near College and Spadina. Details about what's in the kit can be found on the Creatron site and on the Sparkfun site.

I'm not entirely sure what the best starting place is for learning, but these should help:

  • First of all, googling for "arduino tutorials" and the like will get you a lot of useful/helpful stuff. There's a large and vibrant community around this stuff.

  • Sparkfun has a lot of tutorials. I haven't checked them out (yet), and I'm not sure if there's a clear introductory path, but they'll probably be useful along the way. (I'm bookmarking it to go back and read about pull-up resistors, which I've used but don't understand.)

  • The Arduino.cc Foundations page has some pretty good introductory stuff. You should definitely read the three links in the "Programming Technique" section, to help you to read and write sketches.

  • It would be good to work through the Arduino.cc Examples page. (That's where I'm at.) You won't have all the hardware needed for all the examples, but a fair number of them.

  • The Arduino.cc Playground has a lot of good stuff, including links to Introductory tutorials and whatnot.