05c: Running a Program
Objective: To run a program on an Arduino.
The best references for getting started with the Arduino are supplied with the IDE: the Help menu includes a section for Getting Started which covers operation and Reference which covers the language.
In addition, the main Arduino site has similar introduction pages:
The Arduino Tutorial Foundations page addresses many basic ideas and syntax. If you are still a relative novice programmer, please be sure to look at First Sketch, Variables, and Functions.
Program 1: Blink.
- Connect an Arduino Uno to the host computer with the IDE.
- Configure the IDE for the Uno as per the Getting Started guide.
- Load the Examples/01.Basics/Blink sketch. The Examples are found in the File menu, as is the Sketchbook in which you can put your own programs. Your Sketchbook (just like in Processing) is stored in your Documents directory.
- This program uses just the LED onboard the Uno, so no additional external circuit is required.
- Verify/Compile the program to check that the program text is valid.
- Upload to the Uno and check that the LED blinks when the program runs.
- Change the numbers in the
delay
statements; the units are milliseconds. - Re-upload and observe the change in LED behavior.
Program 2: ReadAnalogVoltage.
- Upload the ReadAnalogVoltage sketch.
- Find and open the Serial Monitor. Set it to 9600 baud to match the sketch.
- Observe the measurements of analog noise printed to the monitor. Attach a wire to A0 and touch it with your finger to change the noise input.
- The serial monitor is your primary means for seeing the debugging output from your programs; you should become familiar with the Serial library and printing out text and numbers. Yes: It can be difficult to debug complex programs when the serial port is the only source of information.