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.
- BareMinimum: The bare minimum of code needed to start an Arduino sketch.
- Blink: Turn an LED on and off.
- DigitalReadSerial: Read a switch, print the state out to the Arduino Serial Monitor.
- AnalogReadSerial: Read a potentiometer, print it's state out to the Arduino Serial Monitor.
- Fade: Demonstrates the use of analog output to fade an LED.
- ReadAnalogVoltage : Reads an analog input and prints the voltage to the serial monitor
- 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.
- Input Pullup Serial: Demonstrates the use of INPUT_PULLUP with pinMode().
- 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.
- AnalogInOutSerial: read an analog input pin, map the result, and then use that data to dim or brighten an LED.
- Analog Input: use a potentiometer to control the blinking of an LED.
- AnalogWriteMega: fade 12 LEDs on and off, one by one, using an Arduino Mega board.
- Calibration: define a maximum and minimum for expected analog sensor values.
- Fading: use an analog output (PWM pin) to fade an LED.
- Smoothing: smooth multiple readings of an analog input.
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. For Pd patches that can communicate with these sketches, see Scott Fitzgerald's examples.
- ReadASCIIString: parse a comma-separated string of ints to fade an LED
- ASCII Table: demonstrates Arduino's advanced serial output functions.
- Dimmer: move the mouse to change the brightness of an LED.
- Graph: send data to the computer and graph it in Processing.
- Physical Pixel: turn a LED on and off by sending data to your Arduino from Processing or Max/MSP.
- Virtual Color Mixer: send multiple variables from Arduino to your computer and read them in Processing or Max/MSP.
- Serial Call Response: send multiple vairables using a call-and-response (handshaking) method.
- Serial Call Response ASCII: send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending.
- SerialEvent: Demonstrates the use of SerialEvent().
- Serial input (Switch (case) Statement): how to take different actions based on characters received by the serial port.
- MIDI: send MIDI note messages serially.
- MultiSerialMega: use two of the serial ports available on the Arduino Mega.
- 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
9.USB (Leonardo, Micro, and Due specific examples)
The Keyboard and Mouse examples are unique to the Leonardo, Micro and Due. They demonstrate the use of libraries that are unique to the board.
- KeyboardMessage: Sends a text string when a button is pressed.
- KeyboardLogout : Logs out the current user with key commands
- KeyboardSerial: Reads a byte from the serial port, and sends back a keystroke.
- KeyboardReprogram : opens a new window in the Arduino IDE and reprograms the Leonardo with a simple blink program
Examples from the libraries that are included in the Arduino software.
Esplora Beginner examples
Esplora Expert examples
- EsploraKart : Use the Esplora as a controller to play a kart racing game.
- EsploraTable : Print the Esplora sensor information to a table format.
- EsploraRemote : Connect the Esplora to Processing and control the outputs.
- EsploraPong : Play Pong with the Esplora using Processing.
- Make Voice Call: get your shield to make phone calls from the Serial Monitor
- Receive Voice Call: check the status of the modem while getting voice calls
- Send SMS: use the Serial Monitor to type in SMS messages to different phone numbers
- Receive SMS: read SMS messages and prompt them to the Serial Monitor
- Web Client: download the content of a website to your Arduino board through GPRS
- Web Server: create a wireless web server through GPRS
- Twitter Client: read Twitter from anywhere
- Pachube Client: communicate to the Pachube sensor backbone
- Pachube Client String: communicate to the Pachube sensor backbone
- 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.
- Logo - tell your robot where to go through the on-board keyboard
- Line Following - draw a racing track and get your robot to run on it
- Disco Bot - turn your robot into an 8-bit jukebox and dance to the beat
- Compass - plan a treasure hunt with this digital compass
- Inputs - learn how to control the knob and the keyboard
- Wheel Calibration - tune the wheels to perform even better
- Runaway Robot - play tag with your robot using a distance sensor
- Remote control - reuse that old tv-remote to command the bot on distance
- Picture browser - want to use your own images? This is how
- Rescue - train your robot to look for hidden pearls in a maze
- Hello User - hack the robot's welcome demo and make your own
- Knob: control the shaft of a servo motor by turning a potentiometer.
- Sweep: sweeps the shaft of a servo motor back and forth.
Software Serial Library
- Motor Knob: control a highly accurate stepper motor using a potentiometer.
- TFT Bitmap Logo: Read an image file from a micro-SD card and draw it at random locations.
- TFT Display Text : Read the value of a sensor and print it on the screen.
- TFT Pong: An Arduino implementation of the classic game
- Etch a Sketch: An Arduino version of the classic Etch-a-Sketch
- Color Picker: With three sensors, change the color of the TFT screen
- Graph: Graph the values from a variable resistor to the TFT
Arduino as ISP Programmer
ArduinoISP turns your Arduino into an in-circuit programmer to re-program Atmega chips. Useful when you need to re-load the bootloader on an Arduino, if you're going from Arduino to an Atmega on a breadboard, 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.