Hardware Reference
In-Depth Information
void sendPwm(pin, value) : Sets the PWM value for pins set to ADR_PWM (chosen from pins 3,
5, 6, 9, 10, and 11); the value is between ON (255) and OFF (0).
void sendServo(pin, sweep) : Uses pin 9 or 10 and sends servo signals between 0 and
sweep-angle default 180.
void sendServoAttach(pin, min, max, sweep) : Defines the following servo parameters:
The pin
Minimum pulse width (defaults to 544)
Maximum pulse width (defaults to 2400)
Angle of sweep (defaults to 180)
int getDigital(pin) : Used on pins 2 through 13:
ARD_INPUT returns the last state the pin reported
For pins set as
ARD_OUTPUT returns the last value sent to the pin
For pins set as
int getPwm(pin) : For pins set as ARD_PWM , returns the last set PWM value for the pin
requested (usable pins are 3, 5, 6, 9, 10 and 11, or pins 16 through 21 if analog pins 0 through 5
are set as digital pins).
int getServo(pin) : Returns the last value the servo was set to.
int getAnalog(pin) : Used for analog pins 0 through 5 and returns a value between
0 and1023.
string getString() : Returns the last string received.
int getDigitalPinMode(pin) : Returns ARD_INPUT , ARD_OUTPUT , ARD_PWM , ARD_SERVO , or
ARD_ANALOG .
int getAnalogPinReporting(pin) . For analog pins 0 through 5, returns ARD_ON or ARD_OFF .
Expanding on the Idea
We now have openFrameworks controlling the Arduino, which is running the standard Firmata sketch. The
next example illustrates the increase of efficiency that can be gained in development by having Arduino and
openFrameworks integrated.
1.
Start the next example by attaching a servo to pin 10 and another LED to pin 3, in addition
to the other components from the last example. Use Figure 3-5 for reference.
2.
After the two new components are in place, start the Firmata test app to check that all the
components are working.
3.
Set the pins to the following configuration:
pin3 = PWM
pin8 = input
pin10 = servo
pin13 = output
Analog pin 0
 
Search WWH ::




Custom Search