|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.tue.id.creapro.arduino.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 |
---|
Fields inherited from interface nl.tue.id.creapro.arduino.ArduinoConstants |
---|
HIGH, INPUT, LOW, OUTPUT |
Fields inherited from interface nl.tue.id.creapro.arduino.SerialConstants |
---|
ANALOG_MESSAGE, ANALOG_PULL_INTERVAL, ANALOG_STEP, COMMAND_COUNT, CONFIG, DEBUG, DIGITAL_MESSAGE, EVENT_COUNT, READ_COUNT, REPORT_ANALOG_PIN, REPORT_DIGITAL_PORTS, REPORT_VERSION, SERIAL_PULL_INTERVAL, SET_DIGITAL_PIN_MODE, WRITE_COUNT |
Constructor Summary | |
---|---|
Arduino(processing.core.PApplet parent,
java.lang.String name)
Creates a proxy to an Arduino board running the IDuino firmware. |
|
Arduino(processing.core.PApplet parent,
java.lang.String name,
int rate)
Creates a proxy to an Arduino board running the IDuino firmware. |
Method Summary | |
---|---|
void |
addArduinoListener(ArduinoListener listener)
Registers an input event listener. |
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 |
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 |
removeArduinoListener(ArduinoListener listener)
Removes an listener from the list of listeners. |
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 |
Constructor Detail |
---|
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())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.Method Detail |
---|
public void addArduinoListener(ArduinoListener listener)
listener
- the listener to be registered.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 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 disableAnalogInput(int pin)
pin
- the analog pin to be disabled (from 0 to 5)public void disableDigitalInput(int pin)
pin
- the digital pin to be disabled (from 2 to 13)public void enableAnalogInput(int pin)
pin
- the analog pin to be enabled (from 0 to 5)public void enableDigitalInput(int pin)
pin
- the digital pin to be enabled (from 2 to 13)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 void removeArduinoListener(ArduinoListener listener)
listener
- the listener to be removedpublic 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). 5 by default.public void setSerialPullInterval(int interval)
interval
- the new serial pull interval in milliseconds (0-1023).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |