0% found this document useful (0 votes)
53 views

Examples: Examples Foundations Hacking Links

HomePage

Uploaded by

krishna murti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Examples: Examples Foundations Hacking Links

HomePage

Uploaded by

krishna murti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Search the Arduino Website 

Home Buy Download Products L earning Reference Support Blog L OG IN SIGN UP

Learning Examples | Foundations | Hacking | Links

Examples
See the following examples for an overview of the Arduino Core functions and Libraries; 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.

NOTE: THESE EXAMPLES ARE WRITTEN FOR ARDUINO 1.0 AND LATER.
CERTAIN FUNCTIONS MAY NOT WORK IN EARLIER VERSIONS. FOR BEST RESULTS, DOWNLOAD THE LATEST VERSION.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Core Functions Libraries
Simple programs that demonstrate basic Arduino commands. Examples from the libraries that are included in the Arduino
These are included with the Arduino environment; to open software.
them, click the Open button on the toolbar and look in the
examples folder. Bridge Library (for the Arduino Yún)
- Bridge: Access the pins of the board with a web browser
1.Basics - Console ASCII Table: Demonstrates printing various formats
- BareMinimum: The bare minimum of code needed to start to the Console
an Arduino sketch. - Console Pixel: Control an LED through the Console
- Blink: Turn an LED on and off. - Console Read: Parse information from the Console and
- DigitalReadSerial: Read a switch, print the state out to the repeat it back
Arduino Serial Monitor. - Datalogger: store sensor information on a SD card
- AnalogReadSerial: Read a potentiometer, print it's state out - File Write Script: Demonstrates how to write and execute a
to the Arduino Serial Monitor. shell script with Process
- Fade: Demonstrates the use of analog output to fade an - HTTP Client: create a simple client that downloads a
LED. webpage and prints it to the serial monitor
- ReadAnalogVoltage : Reads an analog input and prints the - Process: demonstrates how to use Process to run Linux
voltage to the serial monitor commands
- Shell Commands: Use Process to run shell commands
2.Digital - Temperature Web Panel: Post sensor data on a webpage
- Blink Without Delay: blinking an LED without using the when requested by a browser
delay() function.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
delay() function. - TimeCheck: get the time from a network time server and
- Button: use a pushbutton to control an LED. print it to the serial monitor.
- Debounce: read a pushbutton, filtering noise. - WiFiStatus: runs a pre-configured script that reports back
- Button State Change: counting the number of button the strength of the current WiFi network
pushes. - Xively Client : send data from multiple sensors to Xively
- Input Pullup Serial: Demonstrates the use of with strings
INPUT_PULLUP with pinMode(). - Yun Serial Terminal: Access the Linux Terminal through the
- Tone: play a melody with a Piezo speaker. serial monitor.
- Pitch follower: play a pitch on a piezo speaker depending on Temboo examples The Temboo website has a section
an analog input. dedicated to the reference of the Temboo library and
- Simple Keyboard: a three-key musical keyboard using force examples contained inside the Arduino IDE. See this page for
sensors and a piezo speaker. more information.
- Tone4: play tones on multiple speakers sequentially using
Spacebrew examples There are a number of examples for
the tone() command.
Spacebrew on the Yún included in the software. For more on
Spacebrew, see the project documentation pages.
3.Analog
- AnalogInOutSerial: read an analog input pin, map the result, Linux tips&tricks

and then use that data to dim or brighten an LED. - Pacakage Manager : how to install additional software on
- Analog Input: use a potentiometer to control the blinking of the Yún.
an LED.
- AnalogWriteMega: fade 12 LEDs on and off, one by one, EEPROM Library
using an Arduino Mega board. - EEPROM Clear: clear the bytes in the EEPROM.

- Calibration: define a maximum and minimum for expected - EEPROM Read: read the EEPROM and send its values to the
analog sensor values. computer.

- Fading: use an analog output (PWM pin) to fade an LED. - EEPROM Write: stores values from an analog input to the
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
- Smoothing: smooth multiple readings of an analog input. EEPROM.

4.Communication Esplora Library

These examples include code that allows the Arduino to talk to Esplora Beginner examples

Processing sketches running on the computer. For more - EsploraBlink : Blink the Esplora's RGB LED

information or to download Processing, see processing.org. - EsploraAccelerometer : Read the values from the
There are also Max/MSP patches that can communicate with accelerometer

each Arduino sketch as well. For more on Max/MSP see Cycling - EsploraJoystickMouse : Use the Esplora's joystick to control

74. For Pd patches that can communicate with these sketches, the cursor on your computer

see Scott Fitzgerald's examples. - EsploraLedShow : Use the Joystick and slider to create a
light show with the LED
- ReadASCIIString: parse a comma-separated string of ints to
- EsploraLedShow2 : Use the Esplora's microphone, linear
fade an LED
potentiometer, and light sensor to change the color of the
- ASCII Table: demonstrates Arduino's advanced serial output
onboard LED.
functions.
- EsploraLightCalibrator : Read the values from the
- Dimmer: move the mouse to change the brightness of an
accelerometer
LED.
- EsploraMusic : Make some music with the Esplora
- Graph: send data to the computer and graph it in
- EsploraSoundSensor : Read the values from the Esplora's
Processing.
microphone
- Physical Pixel: turn a LED on and off by sending data to
- EsploraTemperatureSensor : Read the temperature sensor
your Arduino from Processing or Max/MSP.
and get the temperature in in Farhenheit or Celsius.
- Virtual Color Mixer: send multiple variables from Arduino to
your computer and read them in Processing or Max/MSP. Esplora Expert examples

- Serial Call Response: send multiple vairables using a call- - EsploraKart : Use the Esplora as a controller to play a kart
and-response (handshaking) method. racing game.

open in browser PRO version Are you a developer? Try out the HTML to PDF API
- EsploraTable : Print the Esplora sensor information to a
pdfcrowd.com
- Serial Call Response ASCII: send multiple variables using a - EsploraTable : Print the Esplora sensor information to a
call-and-response (handshaking) method, and ASCII- table format.
encode the values before sending. - EsploraRemote : Connect the Esplora to Processing and
- SerialEvent: Demonstrates the use of SerialEvent(). control the outputs.

- Serial input (Switch (case) Statement): how to take - EsploraPong : Play Pong with the Esplora using Processing.
different actions based on characters received by the
serial port. Ethernet Library
- MIDI: send MIDI note messages serially. - ChatServer: set up a simple chat server.
- MultiSerialMega: use two of the serial ports available on the - WebClient: make a HTTP request.
Arduino Mega. - WebClientRepeating: Make repeated HTTP requests.
- WebServer: host a simple HTML page that displays analog
5.Control Structures sensor values.
- If Statement (Conditional): how to use an if statement to - XivelyClient: connect to xively.com, a free datalogging site.
change output conditions based on changing input - XivelyClientString: send strings to xively.com.
conditions.
- BarometricPressureWebServer: outputs the values from a
- For Loop: controlling multiple LEDs with a for loop and. barometric pressure sensor as a web page.
- Array: a variation on the For Loop example that - UDPSendReceiveString: Send and receive text strings via
demonstrates how to use an array. UDP.
- While Loop: how to use a while loop to calibrate a sensor - UdpNtpClient: Query a Network Time Protocol (NTP) server
while a button is being read. using UDP.
- Switch Case: how to choose between a discrete number of - DnsWebClient: DNS and DHCP-based Web client.
values. Equivalent to multiple If statements. This example
- DhcpChatServer: A simple DHCP Chat Server
shows how to divide a sensor's range into a set of four
- DhcpAddressPrinter: Get an IP address via DHCP and print it
bands and to take four different actions depending on
out
which band the result is in.
- TelnetClient: A simple Telnet client
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
- TelnetClient: A simple Telnet client
- Switch Case 2: a second switch-case example, showing how
to take different actions based in characters received in
the serial port. Firmata Libraries
- Guide to the Standard Firmata Library
6.Sensors
- ADXL3xx: read an ADXL3xx accelerometer. GSM Library
- Knock: detect knocks with a piezo element. GSM Examples

- Memsic2125 : two-axis acceleromoter. - Make Voice Call: get your shield to make phone calls from
- Ping: detecting objects with an ultrasonic range finder. the Serial Monitor
- Receive Voice Call: check the status of the modem while
7.Display getting voice calls
- Send SMS: use the Serial Monitor to type in SMS messages
Examples of basic display control
to different phone numbers
- LED Bar Graph: how to make an LED bar graph.
- Receive SMS: read SMS messages and prompt them to the
- Row Column Scanning: how to control an 8x8 matrix of
Serial Monitor
LEDs.
- Web Client: download the content of a website to your
Arduino board through GPRS
8.Strings
- Web Server: create a wireless web server through GPRS
- StringAdditionOperator: add strings together in a variety of
- Xively Client: communicate to the Xively sensor backbone
ways.
- Xively Client String: communicate to the Xively sensor
- StringAppendOperator: append data to strings.
backbone
- StringCaseChanges: change the case of a string.
GSM Tools
- StringCharacters: get/set the value of a specific character in
a string. - Test Modem: read the IMEI of your modem

- StringComparisonOperators: compare strings - Test GPRS: test the proper functionality of the GPRS
network using your SIM card
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
alphabetically. network using your SIM card

- StringConstructors: how to initialize string objects. - GSM Scan Networks: check for the available networks

- StringIndexOf: look for the first/last instance of a character - Pin Management: manage the PIN number of your SIM card
in a string. - Band Management: manage the band the GSM shield
- StringLength & StringLengthTrim: get and trim the length connects to.
of a string. - Test Web Server: Create a webserver with your GSM shield
- StringReplace: replace individual characters in a string.
- StringStartsWithEndsWith: check which LiquidCrystal Library
characters/substrings a given string starts or ends with. - Hello World: displays "hello world!" and the seconds since
- StringSubstring: look for "phrases" within a given string. reset.
- Blink: control of the block-style cursor.
9.USB (Leonardo, Micro, and Due specific - Cursor: control of the underscore-style cursor.
examples) - Display: quickly blank the display without losing what's on
The Keyboard and Mouse examples are unique to the it.
Leonardo, Micro and Due. They demonstrate the use of - TextDirection: control which way text flows from the cursor.
libraries that are unique to the board. - Scroll: scroll text left and right.
- KeyboardAndMouseControl: Demonstrates the Mouse and - Serial input: accepts serial input, displays it.
Keyboard commands in one program. - SetCursor: set the cursor position.
- Autoscroll: shift text right and left.
Keyboard
- KeyboardMessage: Sends a text string when a button is Robot Library
pressed. - Logo - tell your robot where to go through the on-board
- KeyboardLogout : Logs out the current user with key keyboard
commands - Line Following - draw a racing track and get your robot to

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
- KeyboardSerial: Reads a byte from the serial port, and sends run on it
back a keystroke. - Disco Bot - turn your robot into an 8-bit jukebox and dance
- KeyboardReprogram : opens a new window in the Arduino to the beat
IDE and reprograms the Leonardo with a simple blink - Compass - plan a treasure hunt with this digital compass
program
- Inputs - learn how to control the knob and the keyboard
- Wheel Calibration - tune the wheels to perform even better
Mouse
- Runaway Robot - play tag with your robot using a distance
- ButtonMouseControl: Control cursor movement with 5
sensor
pushbuttons.
- Remote control - reuse that old tv-remote to command the
- JoystickMouseControl: Controls a computer's cursor
bot on distance
movement with a Joystick when a button is pressed.
- 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

SPI Library
- BarometricPressureSensor: read air pressure and
temperature from a sensor using the SPI protocol.
- SPIDigitalPot: control a AD5206 digital potentiometer using
the SPI protocol.

Servo Library
- Knob: control the shaft of a servo motor by turning a

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
potentiometer.
- Sweep: sweeps the shaft of a servo motor back and forth.

So ware Serial Library


- Software Serial Example: how to use the SoftwareSerial
Library...Because sometimes one serial port just isn't
enough!
- Two Port Receive: how to work with multiple software serial
ports.

Stepper Library
- Motor Knob: control a highly accurate stepper motor using
a potentiometer.

TFT Library
Esplora
- Esplora TFT Bitmap Logo: Read an image file from a micro-
SD card and draw it at random locations.
- Esplora TFT Color Picker: Using the joystick and slider,
change the color of the TFT screen
- Esplora TFT Etch a Sketch: An Esplora implementation of
the classic Etch-a-Sketch
- Esplora TFT Graph: Graph the values from the light sensor
to the TFT

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
- Esplora TFT Horizon: Draw an artificial horizon line based on
the tilt from the accelerometer
- Esplora TFT Pong: A basic implementation of the classic
game
- Esplora TFT Temperature: Check the temperature with the
onboard sensor and display it on screen
Arduino
- 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

Wire Library
- SFRRanger_reader: read a Devantech SRFxx ultra-sonic
range finder using I2C communication.
- digital_potentiometer: control a AD5171 digital pot using
the Wire Library.
- master reader/slave sender: set up two (or more) arduino

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
boards to share information via a master reader/slave
sender configuration.
- master writer/slave reader: allow two (or more) arduino
boards to share information using a master writer/slave
reader set up.

WiFi Library
- ConnectNoEncryption : Demonstrates how to connect to an
open network
- ConnectWithWEP : Demonstrates how to connect to a
network that is encrypted with WEP
- ConnectWithWPA : Demonstrates how to connect to a
network that is encrypted with WPA2 Personal
- ScanNetworks : Displays all WiFi networks in range
- WiFiChatServer : Set up a simple chat server
- WiFiXivelyClient : connect to xively.com, a free datalogging
site
- WiFiXivelyClientString: send strings to xively.com
- WiFiWebClient : Connect to a remote webserver
- WiFiWebClientRepeating: Repeatedly make HTTP calls to a
server
- WiFiWebServer : Serve a webpage from the WiFi shield

open in browser PRO version Are you a developer? Try out the HTML to PDF API
Arduino as ISP pdfcrowd.com
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.

More
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.

Writing examples
Here's a style guide that helps with writing examples for
beginners.

Like 975 Tw eet 132 1.3K

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
©Arduino Copyright Notice Contact us

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com

You might also like