Built-in Examples

Learn the basics of Arduino through this collection tutorials. All code examples are available directly in all IDEs.


Analog Read Serial

Read a potentiometer, print its state out to the Arduino Serial Monitor.

Bare Minimum code needed

The bare minimum of code needed to start an Arduino sketch.


Turn an LED on and off every second.

Digital Read Serial

Read a switch, print the state out to the Arduino Serial Monitor.

Fading a LED

Demonstrates the use of analog output to fade an LED.

Read Analog Voltage

Reads an analog input and prints the voltage to the Serial Monitor.


Blink Without Delay

Blink an LED without using the delay() function.

How to Wire and Program a Button

Learn how to wire and program a pushbutton to control an LED.

Debounce on a Pushbutton

Read a pushbutton, filtering noise.


Demonstrates the use of INPUT_PULLUP with pinMode()

Simple keyboard using the tone() function

A three-key musical keyboard using force sensors and a piezo speaker.

Play a Melody using the tone() function

Play a melody with a Piezo speaker.

Tone on Multiple Speakers

Play tones on multiple speakers sequentially using the tone() command.

Pitch follower using the tone() function

Play a pitch on a piezo speaker depending on an analog input.


Analog In, Out Serial

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.

Analog Write with 12 LEDs on an Arduino Mega

Fade 12 LEDs on and off, one by one, using an Arduino Mega board.

Calibrate Sensor Input

Define a maximum and minimum for expected analog sensor values.


Use an analog output (PWM pin) to fade an LED.

Smoothing Readings From an Analog Input

Smooth multiple readings of an analog input.



Demonstrates advanced Arduino serial output functions.

Create a LED Dimmer

Move the mouse to change the brightness of an LED.

Create a Graph with Processing

Send data to the computer and graph it in Processing.

MIDI Note Player

Send MIDI note messages serially.

Use Multiple Serial Ports on the Arduino Mega

Use two of the serial ports available on the Arduino Mega.

Physical Pixel

Turn a LED on and off by sending data to your Arduino from Processing or Max/MSP.

Read ASCII String

Parse a comma-separated string of integers to fade an LED.

Serial Call and Response (handshaking)

Send multiple variables using a call-and-response (handshaking) method.

Serial Call and Response (handshaking) with ASCII-encoded output

Send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending.


Demonstrates the use of serialEvent() function.


Demonstrates how to virtually connect Serial and Serial1.

Virtual Color Mixer

This example demonstrates how to send multiple values from the Arduino board to the computer.

Control Structures

How to Use Arrays

A variation on the For Loop example that demonstrates how to use an array.

For Loop Iteration (aka The Knight Rider)

Control multiple LEDs with a for loop and.

Switch (case) Statement, used with sensor input

How to choose between a discrete number of values.

Switch (case) Statement, used with serial input

A second switch-case example, showing how to take different actions based on the characters received in the serial port.

While Loop

How to use a while loop to calibrate a sensor while a button is being read.

If Statement (Conditional Statement)

Use an if statement to change the output conditions based on changing the input conditions.


ADXL3xx Accelerometer

Read an ADXL3xx accelerometer.

Detect a Knock

This tutorial shows you how to use a Piezo element to detect vibration.

Memsic 2125 Accelerometer

Learn how to read data from the Memsic 2125 Two-axis accelerometer.

Ping Ultrasonic Range Finder

Detect objects with an ultrasonic range finder.


LED Bar Graph

Learn how to make an LED bar graph - a series of LEDs in a line.

Control an 8x8 matrix of LEDs.

Row-column Scanning to control an 8x8 LED Matrix.


Character Analysis

Use the operators to recognise the type of character we are dealing with.

String Addition Operator

Add strings together in a variety of ways.

String Appending Operators

Use the += operator and the concat() method to append things to Strings.

String Case Change Functions

Change the case of a string.

String Character Functions

Get/set the value of a specific character in a string.

String Comparison Operators

Learn how to make alphabetic comparisons between Strings. They are useful for sorting and alphabetizing, among other things.

String Object Constructors

Initialize string objects.

String indexOf() and lastIndexOf() Method

Look for the first/last instance of a character in a string.

How to Use String length()

This example shows you how to use this command to reply to an input from the Serial Monitor.

String length() and trim() Commands

Get and trim the length of a string.

String replace Function

The replace() function allows you to replace all instances of a given character in a string with another character.

String startsWith and endsWith Functions

Check which characters/substrings a given string starts or ends with.

String substring Function

Look for "phrases" within a given string.

String to Int Function

Allows you to convert a String to an integer number.


Button Mouse Control

Control cursor movement with 5 pushbuttons.

Joystick Mouse Control

Controls a computer cursor movement with a Joystick when a button is pressed.

Keyboard and Mouse Control

Demonstrates the Mouse and Keyboard commands in one program.

Keyboard Logout

Logs out the current user with key commands.

Keyboard Message

Sends a text string when a button is pressed.

Keyboard Reprogram

Opens a new window in the Arduino IDE and reprograms the Leonardo with a simple blink program.

Keyboard Serial

Reads a byte from the serial port, and sends back a keystroke.

Arduino ISP

Arduino as ISP and Arduino Bootloaders

Arduino ISP turns your Arduino into an in-circuit programmer to re-program AtMega chips.

From Arduino to a Microcontroller on a Breadboard

Migrating an Arduino board to a standalone microcontroller on a breadboard.