|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.tue.id.creapro.Arduino
public class Arduino
Together with the IDuino 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, reacting on the input data when available.
Nested Class Summary | |
---|---|
class |
Arduino.SerialProxy
This class is not intended to be used elsewhere. |
Field Summary | |
---|---|
static int |
HIGH
Constant to write a high value (+5 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 low value (0 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(processing.core.PApplet parent,
java.lang.String name)
Create a proxy to an Arduino board running the IDuino firmware. |
|
Arduino(processing.core.PApplet parent,
java.lang.String name,
int rate)
Create a proxy to an Arduino board running the IDuino firmware. |
Method Summary | |
---|---|
int |
analogRead(int pin)
Reads the last known value read from the analog pin: 0 (0 volts) to 1023 (5 volts). |
void |
analogWrite(int pin,
int value)
Writes an analog value (PWM wave) to a 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 |
disableAnalogInput(int pin)
Disables a particular analog input pin. |
void |
disableDigitalInput(int pin)
Disables a particular digital input pin. |
void |
dispose()
Disposes the serial proxy. |
void |
enableAnalogInput(int pin)
Enables a particular analog input pin, otherwise no input from this pin will be reported to the host computer. |
void |
enableDigitalInput(int pin)
Enables a particular digital input pin, otherwise no input from this pin will be reported to the host computer. |
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 |
setAnalogPullInterval(int interval)
Sets the analog pull interval (ms). |
void |
setAnalogStep(int step)
Sets the setup of the analog input value. |
void |
setSerialPullInterval(int interval)
Sets the serial pull interval (ms). |
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(processing.core.PApplet parent, java.lang.String name, int rate)
parent
- the Processing sketch creating this Arduino board (i.e.
"this").name
- the name of the serial device associated with the Arduino
board (e.g. one the elements of the array returned by Arduino.list())rate
- the baud rate to use to communicate with the Arduino board.public Arduino(processing.core.PApplet parent, java.lang.String name)
parent
- the Processing sketch creating this Arduino board (i.e.
"this").name
- the name of the serial device associated with the Arduino
board (e.g. one the elements of the array returned by Arduino.list())Method Detail |
---|
public static java.lang.String[] list()
public void pinMode(int pin, int mode)
pin
- the pin whose mode to set (from 2 to 13)mode
- either Arduino.INPUT or Arduino.OUTPUTpublic 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 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 enableAnalogInput(int pin)
pin
- the analog pin to be enabled (from 0 to 5)public void disableAnalogInput(int pin)
pin
- the analog pin to be disabled (from 0 to 5)public void enableDigitalInput(int pin)
pin
- the digital pin to be enabled (from 2 to 13)public void disableDigitalInput(int pin)
pin
- the digital pin to be disabled (from 2 to 13)public int analogRead(int pin)
pin
- the analog pin whose value should be returned (from 0 to 5)
public void analogWrite(int pin, int value)
pin
- the pin to write tovalue
- the duty cycle: between 0 (always off) and 255 (always on).public void setSerialPullInterval(int interval)
interval
- the new serial pull interval in milliseconds (0-1023).public void setAnalogPullInterval(int interval)
interval
- the new analog pull interval in milliseconds (0-1023).public void setAnalogStep(int step)
step
- the new analog step (0-1023)public void dispose()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |