|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.firmata.Firmata
public class Firmata
Internal class used by the Arduino class to parse the Firmata protocol.
Nested Class Summary | |
---|---|
static interface |
Firmata.Writer
An interface that the Firmata class uses to write output to the Arduino board. |
Field Summary | |
---|---|
static int |
ANALOG
Constant to set a pin to analog mode (in a call to pinMode()). |
static int |
HIGH
Constant to write a low value (0 volts) to a pin (in a call to digitalWrite()). |
static int |
I2C
Constant to set a pin to I2C mode (in a call to pinMode()). |
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()). |
static int |
PWM
Constant to set a pin to PWM mode (in a call to pinMode()). |
static int |
SERVO
Constant to set a pin to servo mode (in a call to pinMode()). |
static int |
SHIFT
Constant to set a pin to shiftIn/shiftOut mode (in a call to pinMode()). |
Constructor Summary | |
---|---|
Firmata(Firmata.Writer writer)
Create a proxy to an Arduino board running the Firmata 2 firmware. |
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 |
init()
|
void |
pinMode(int pin,
int mode)
Set a digital pin to input or output mode. |
void |
processInput(int inputData)
|
void |
servoWrite(int pin,
int value)
Write a value to a servo pin. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INPUT
public static final int OUTPUT
public static final int ANALOG
public static final int PWM
public static final int SERVO
public static final int SHIFT
public static final int I2C
public static final int LOW
public static final int HIGH
Constructor Detail |
---|
public Firmata(Firmata.Writer writer)
writer
- an instance of the Firmata.Writer interfaceMethod Detail |
---|
public void init()
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.OUTPUTpublic 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)value
- the value: 0 being the lowest (always off), and 255 the highest
(always on)public void servoWrite(int pin, int value)
pin
- the pin the servo is attached tovalue
- the value: 0 being the lowest angle, and 180 the highest anglepublic void processInput(int inputData)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |