Вы находитесь на странице: 1из 3

Search the Arduino Playground

Manuals and Curriculum


(http://playground.arduino.cc/Main/ManualsAndCurriculum)
Arduino StackExchange
(http://arduino.stackexchange.com)
Board Setup and Configuration
(http://playground.arduino.cc/Main/ArduinoCoreHardware)
Processing (http://processing.org/) is an open source language/ development tool for writing
Development Tools
programs in other computers. Useful when you want those other computers to "talk" with an
(http://playground.arduino.cc/Main/DevelopmentTools)
Arduino, for instance to display or save some data collected by the Arduino.
Arduino on other Chips
(http://playground.arduino.cc/Main/ArduinoOnOtherAtmelChips)
Interfacing With Hardware
(http://playground.arduino.cc/Main/InterfacingWithHardware)

Arduino and Processing

Output

Simple Examples

(http://playground.arduino.cc/Main/InterfacingWithHardware#Output)
-

Arduino comes with some basic examples for communicating with Processing (in Examples >
Communication). These are useful for when you want to write both Arduino and Processing programs
(http://playground.arduino.cc/Main/InterfacingWithHardware#InputTOC)
and have them talk to each other. This works best for communicating simple information. If you just
User Interface
want to control an Arduino board from a Processing program, you may want to use the Arduino library
(http://playground.arduino.cc/Main/InterfacingWithHardware#ui)
for Processing described below.
Storage
Input

(http://playground.arduino.cc/Main/InterfacingWithHardware#Storage)
-

Communication

Arduino Library for Processing (and Firmata)

(http://playground.arduino.cc/Main/InterfacingWithHardware#Communication)
-

Power supplies

(http://playground.arduino.cc/Main/IntWithHWThis library

allows you to control an Arduino board from Processing without writing code for the
Arduino. Instead, you upload a standard firmware (program) to the board and communicate with it
General
using the library. The firmware is called Firmata, and is included in the Arduino software. The
(http://playground.arduino.cc/Main/InterfacingWithHardware#General)
corresponding Processing library can be downloaded below.
PwrSup)

Interfacing with Software


(http://playground.arduino.cc/Main/InterfacingWithSoftware)
Download
User Code Library
(http://playground.arduino.cc/Main/GeneralCodeLibrary)
-

Library for Processing v2.0: processing2-arduino.zip


(http://playground.arduino.cc/uploads/Interfacing/processing2-arduino.zip) (Updated 6 Nov. 2013)
(http://playground.arduino.cc/Main/SketchList)
(properties file here: processing2-arduino.txt
Libraries
(http://playground.arduino.cc/uploads/Interfacing/processing2-arduino.txt))
Snippets and Sketches

(http://playground.arduino.cc/Main/LibraryList)
-

Tutorials

Library for
(http://playground.arduino.cc/Main/TutorialList)

Processing v1.5: processing-arduino.zip


(http://playground.arduino.cc/uploads/Interfacing/processing-arduino.zip)
(Updated 11 Nov. 2011)
Suggestions & Bugs
(properties file here: processing-arduino.txt
(https://github.com/arduino/arduino/issues)
Electronics Technique
(http://playground.arduino.cc/uploads/Interfacing/processing-arduino.txt))

(http://playground.arduino.cc/Main/ElectroInfoResources)
Sources for Electronic Parts
Note: if you run Linux, you need to change Arduino.jar into arduino.jar, because Linux is case sensitive
(http://playground.arduino.cc/Main/Resources)
Related Hardware and Initiatives
and it does not work if you don't change this letter (Arduino.jar is in the folder "library" of this
(http://playground.arduino.cc/Main/SimilarBoards)
Processing Library).
Arduino People/Groups & Sites
(http://playground.arduino.cc/Main/People)
Exhibition
Instructions
(http://playground.arduino.cc/Projects/ArduinoUsers)
Project Ideas
1. Unzip the library and copy the "arduino" folder into the "libraries" sub-folder of your Processing
(http://playground.arduino.cc/Projects/Ideas)
Sketchbook. (You can find the location of your Sketchbook by opening the Processing Preferences. If
Languages
(http://playground.arduino.cc/Main/Languages)

you haven't made a "libraries" sub-folder, create one.)

2. Run Arduino, open the Examples > Firmata > StandardFirmata sketch, and upload it to the Arduino

Participate
board.
(http://playground.arduino.cc/Main/Participate)
-

Formatting guidelines

3. Configure Processing for serial: http://processing.org/reference/libraries/serial/

(http://playground.arduino.cc/Main/Participate#contribrules)
(http://processing.org/reference/libraries/serial/)
All recent changes

4. In Processing, open one of the examples that comes with with the Arduino library.

(http://playground.arduino.cc/Site/AllRecentChanges)
-

PmWiki

5. Edit the example code to select the serial port used by Arduino. Specifically, change the [0] in this

(http://playground.arduino.cc/PmWiki/PmWiki)
line

WikiSandBox training
arduino = new Arduino(this, Arduino.list()[0], 57600);
(http://playground.arduino.cc/Main/WikiSandbox)
Basic Editing

To find the correct item in the array, run this code in Processing:

import processing.serial.*;
(http://playground.arduino.cc/PmWiki/BasicEditing)
import cc.arduino.*;
println(Arduino.list());
Documentation index

(http://www.pmwiki.org/wiki/PmWiki/DocumentationIndex)
The output window

will enumerate your serial ports. Select the number corresponding to the serial

port in your Arduino environment found under Tools > Serial Port.
6. Run the example.
Reference
These functions are in the Processing Arduino Library and communicate (from Processing) with a
Arduino, upon which the Firmata sketch has been installed.
Arduino.list(): returns a list of the available serial devices. If your Arduino board is connected to the
computer when you call this function, its device will be in the list.
Arduino(parent, name, rate): create an Arduino object. Parent should be "this" (without the quotes);
name is the name of the serial device (i.e. one of the names returned by Arduino.list()); rate is the
speed of the connection (typically 57600). Note that in the v2 library, the rate parameter is optional.
pinMode(pin, mode): set a digital pin to input, output, or servo mode (Arduino.INPUT,
Arduino.OUTPUT, or Arduino.SERVO).
digitalRead(pin): returns the value of a digital pin, either Arduino.LOW or Arduino.HIGH (the pin must
be set as an input).
digitalWrite(pin, value): writes Arduino.LOW or Arduino.HIGH to a digital pin.
analogRead(pin): returns the value of an analog input (from 0 to 1023).
analogWrite(pin, value): writes an analog value (PWM wave) to a digital pin that supports it (pins 3, 5,
6, 9, 10, and 11); value should be from 0 (always off) to 255 (always on).
servoWrite(pin, value): writes a value to a servo motor; value should be from 0 to 180.
Example
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
void setup()
{
//println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
}
void draw()
{
arduino.digitalWrite(ledPin, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(ledPin, Arduino.LOW);
delay(1000);
}

Another example

Hacking a Processing Sketch for Firmata (Firmata 101)


(http://playground.arduino.cc/Interfacing/ProcesssHackForFirmata)

Troubleshooting
If you're having trouble getting this to work, you can ask for help in the Arduino Forum
(http://forum.arduino.cc/index.php?board=12.0). If you've found a bug in the Arduino (Firmata) library
for Processing, please report it on the GitHub issues list
(https://github.com/firmata/processing/issues).

External Resources
-

Arduino meets processing from K3, malmoe (http://webzone.k3.mah.se/projects/arduinoworkshop/projects/arduino_meets_processing/instructions/index.html) with several examples
for creating graphics from digital and analog sensor input

Tom Igoe's section on Processing


(http://www.tigoe.net/pcomp/code/category/category/Processing) with several communication
and signal postprocessing examples

Pp. 169-176 in the "Physical Computing" book, by Dan O'Sullivan and Tom Igoe (preview in Google
books (http://books.google.com/books?
id=6JRcqhVUszEC&printsec=frontcover&sig=IwzAFztiEncCES8Xa47mQWlVgmI#PPA170,M1))

You can also use the SimpleMessageSystem


(http://playground.arduino.cc/Code/SimpleMessageSystem) to communicate with Processing.
Check the example in the download.

Share

NEWSLETTER

Enter your email to sign up

2015 Arduino

Copyright Notice (http://arduino.cc/en/Main/CopyrightNotice)

(https://twitter.com/arduino)
(https://plus.google.com/+Arduino)
(http://youtube.com/arduinoteam)

Contact us (http://arduino.cc/en/Main/ContactUs)

(http://www.facebook.com/official.arduino)
(http://www.flickr.com/photos/arduino_cc)

Вам также может понравиться