|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcc.arduino.Arduino
public class Arduino
Together with the firmata firmware (an Arduino sketch uploaded to the Arduino board), this class allows you to control the Arduino board from Processing: reading from and writing to the digital pins and reading the analog inputs.
| Nested Class Summary | |
|---|---|
class |
Arduino.SerialProxy
|
| Field Summary | |
|---|---|
static int |
HIGH
Constant to write a low value (0 volts) to a pin (in a call to digitalWrite()). |
static int |
INPUT
Constant to set a pin to input mode (in a call to pinMode()). |
static int |
LOW
Constant to write a high value (+5 volts) to a pin (in a call to digitalWrite()). |
static int |
OUTPUT
Constant to set a pin to output mode (in a call to pinMode()). |
| Constructor Summary | |
|---|---|
Arduino(PApplet parent,
java.lang.String iname,
int irate)
Create a proxy to an Arduino board running the firmata firmware (used with PDuino). |
|
| Method Summary | |
|---|---|
int |
analogRead(int pin)
Returns the last known value read from the analog pin: 0 (0 volts) to 1023 (5 volts). |
void |
analogWrite(int pin,
int value)
Write an analog value (PWM-wave) to a digital pin. |
int |
digitalRead(int pin)
Returns the last known value read from the digital pin: HIGH or LOW. |
void |
digitalWrite(int pin,
int value)
Write to a digital pin (the pin must have been put into output mode with pinMode()). |
void |
dispose()
|
static java.lang.String[] |
list()
Get a list of the available Arduino boards; currently all serial devices (i.e. |
void |
pinMode(int pin,
int mode)
Set a digital pin to input or output mode. |
void |
servoAttach(int pin)
Initialize servo timer routines on a pin. |
void |
servoDetach(int pin)
Stop pulse output to a pin. |
void |
servoSetMaxPulseTime(int pin,
int value)
Set the pulse duration (in microseconds) that causes a servo to rotate to its upper limit. |
void |
servoSetMinPulseTime(int pin,
int value)
Set the pulse duration (in microseconds) that causes a servo to rotate to its lower limit. |
void |
servoWrite(int pin,
int value)
Write a servo angle to an output pin. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int INPUT
public static final int OUTPUT
public static final int LOW
public static final int HIGH
| Constructor Detail |
|---|
public Arduino(PApplet parent,
java.lang.String iname,
int irate)
parent - the Processing sketch creating this Arduino board
(i.e. "this").iname - the name of the serial device associated with the Arduino
board (e.g. one the elements of the array returned by Arduino.list())irate - the baud rate to use to communicate with the Arduino board
(this depends on the firmata version used: 0.1 is at 19200, 0.2 at 115200,
1.0 at 57600)| Method Detail |
|---|
public void dispose()
public static java.lang.String[] list()
public int digitalRead(int pin)
pin - the digital pin whose value should be returned (from 2 to 13,
since pins 0 and 1 are used for serial communication)public int analogRead(int pin)
pin - the analog pin whose value should be returned (from 0 to 5)
public void pinMode(int pin,
int mode)
pin - the pin whose mode to set (from 2 to 13)mode - either Arduino.INPUT or Arduino.OUTPUT
public void digitalWrite(int pin,
int value)
pin - the pin to write to (from 2 to 13)value - the value to write: Arduino.LOW (0 volts) or Arduino.HIGH
(5 volts)
public void analogWrite(int pin,
int value)
pin - the pin to write to (must be 9, 10, or 11, as those are they
only ones which support hardware pwm)the - value: 0 being the lowest (always off), and 255 the highest
(always on)
public void servoWrite(int pin,
int value)
pin - the pin to write to (must be 2-13 on arduino)the - value as an angle: 0 being the minimum, and 180 the maximumpublic void servoAttach(int pin)
pin - the pin to attach the servo to (must be 2-13 on arduino)public void servoDetach(int pin)
pin - the pin to detach the servo from (must be 2-13 on arduino)
public void servoSetMinPulseTime(int pin,
int value)
pin - the pin to write to (must be 2-13 on arduino)value - pulse duration in microseconds
public void servoSetMaxPulseTime(int pin,
int value)
pin - the pin to write to (must be 2-13 on arduino)value - pulse duration in microseconds
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||