Learning Examples | Foundations | Hacking | Links
See the foundations page for in-depth description of core concepts of the Arduino hardware and software; the hacking page for information on extending and modifying the Arduino hardware and software; and the links page for other documentation.
Here's a style guide that helps with writing examples for beginners.
Simple programs that demonstrate basic Arduino commands. These are included with the Arduino environment; to open them, click the Open button on the toolbar and look in the examples folder.
- Blink turn an LED on and off.
- Blink Without Delay: blinking an LED without using the delay() function.
- Button: use a pushbutton to control an LED.
- Debounce: read a pushbutton, filtering noise.
- Button State Change counting the number of button pushes
- Tone: play a melody with a Piezo speaker.
- Pitch follower: play a pitch on a piezo speaker depending on an analog input
- Simple Keyboard A three-key musical keyboard using force sensors and a piezo speaker.
- Tone4 Play tones on multiple speakers sequentially using the tone() command.
These examples include code that allows the Arduino to talk to Processing sketches running on the computer. For more information or to download Processing, see processing.org. There are also Max/MSP patches that can communicate with each Arduino sketch as well. For more on Max/MSP see Cycling 74
- ASCII Table: demonstrates Arduino's advanced serial output functions.
- Dimmer: move the mouse to change the brightness of an LED.
- Graph: sending data to the computer and graphing it in Processing.
- Physical Pixel: turning on and off an LED by sending data from Processing.
- Virtual Color Mixer: sending multiple variables from Arduino to the computer and reading them in Processing.
- Serial Call Response: sending multiple vairables using a call-and-response (handshaking) method.
- Serial Call Response ASCII: sending multiple vairables using a call-and-response (handshaking) method, and ASCII-encoding the values before sending.
- Serial input how to take different actions based in characters received in the serial port.
- MIDI How to send MIDI note messages serially.
- If Statement (Conditional): how to use an if statement to change output conditions based on changing input conditions.
- For Loop: controlling multiple LEDs with a for loop and.
- Array: A variation on the For Loop example that demonstrates how to use an array.
- While Loop: how to use a while loop to calibrate a sensor while a button is being read.
- Switch Case: how to choose between a discrete number of values. Equivalent to multiple If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.
- Switch Case 2 A second switch-case example, showing how to take different actions based in characters received in the serial port.
- ADXL3xx: Read an ADXL3xx accelerometer.
- Knock: detect knocks with a piezo element.
- Memsic2125 : two-axis acceleromoter
- Ping: detecting objects with an ultrasonic range finder
Examples of basic display control
Examples from the libraries that are included in the Arduino software.
- Hello World - displays "hello world!" and the seconds since reset
- Blink - control of the block-style cursor
- Cursor - control of the underscore-style cursor
- Display - quickly blank the display without losing what's on it.
- TextDirection - control which way text flows from the cursor
- Scroll - scroll text left and right
- Serial input - accepts serial input, displays it
- SetCursor - set the cursor position
- Autoscroll - shift text right and left
- Knob: control the shaft of a servo motor by turning a potentiometer.
- Sweep: sweeps the shaft of a servo motor back and forth.
- Motor Knob: control a stepper motor with a potentiometer.
Arduino as ISP Programmer
ISP programmer Turn your Arduino into an in-circuit programmer to re-program Atmega chips. Useful when you need to re-load the bootloader on an Arduino, or if you're making your own Arduino-compatible circuit on a breadboard.
For a huge list of examples from the Arduino community, see the interfacing with hardware page on the playground wiki. Also see the list of old examples.