Hardware Reference
In-Depth Information
Key Constants Used by ofArduino
ofArduino defines some useful constants for more readable code. The following list is a reference of names and values
of the constants. The first part of the constants, ARD , is short for Arduino , and is a reminder that this is dealing with the
hardware. The second part is the type—for example, the pin modes or state declarations.
Pin modes:
ARD_INPUT = 0x00
ARD_OUTPUT = 0x01
ARD_ANALOG = 0x02
ARD_PWM = 0x03
ARD_SERVO = 0x04
Pin states:
ARD_HIGH or ARD_ON = 1
ARD_LOW or ARD_OFF = 0
ofArduino Reference of Class Functions
The following list is a reference for the class functions that make up the ofArduino class. The functions that are
included in the ofArduino class are used to control and connect to Arduinos that have the standard Firmata sketch
loaded. Most of the functions are a direct counterpart of the functions used in the Arduino IDE and work the same
way; for example, sendDigital() is the same as digitalWrite() . The functions require an ofArduino object declared
before they can be used. You can connect multiple Arduinos to the same computer by declaring separate objects for
each Arduino.
bool Connect(port, speed) : Opens an Arduino connection on a serial port and takes a
string for the device connection, such as /dev/ttyUSB0 , COM4 or /dev/tty.usbserial-A4001JEC .
The second parameter is for nondefault baud speeds and can be omitted in
standard configurations.
void disconnect() : Releases the Arduino connection.
bool isInitialized() : Returns true if a successful connection has been established and the
Arduino has reported that firmware from the Firmata sketch has been uploaded.
void update() : Used to update the current state of the Arduino's incoming information; this
should be called regularly.
void sendDigitalPinMode(pin, mode) : Sets the pin mode of a digital pin (one of pins 2
through 13) and sets the pin as one of the digital modes of ARD_INPUT , ARD_OUTPUT , ARD_PWM , or
ARD_SERVO . If the pin is an input, the reporting will be turned on.
void sendAnalogPinReporting(pin, mode) : For analog pins 0 through 5, turns the reporting
to ARD_ON or ARD_OFF . Analog pins can be used as digital pins 16 through 21 or as PWM pins.
The whole group is either analog or digital.
void sendDigital(pin, state) : Sets the state of the specified digital pin to either ARD_LOW or
ARD_HIGH .
 
Search WWH ::




Custom Search