Created
January 30, 2014 14:05
-
-
Save pixelpusher/8709008 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
arduino_output | |
Demonstrates the control of digital pins of an Arduino board running the | |
StandardFirmata firmware. Clicking the squares toggles the corresponding | |
digital pin of the Arduino. | |
To use: | |
* Using the Arduino software, upload the StandardFirmata example (located | |
in Examples > Firmata > StandardFirmata) to your Arduino board. | |
* Run this sketch and look at the list of serial ports printed in the | |
message area below. Note the index of the port corresponding to your | |
Arduino board (the numbering starts at 0). (Unless your Arduino board | |
happens to be at index 0 in the list, the sketch probably won't work. | |
Stop it and proceed with the instructions.) | |
* Modify the "arduino = new Arduino(...)" line below, changing the number | |
in Arduino.list()[0] to the number corresponding to the serial port of | |
your Arduino board. Alternatively, you can replace Arduino.list()[0] | |
with the name of the serial port, in double quotes, e.g. "COM5" on Windows | |
or "/dev/tty.usbmodem621" on Mac. | |
* Run this sketch and click the squares to toggle the corresponding pin | |
HIGH (5 volts) and LOW (0 volts). (The leftmost square corresponds to pin | |
13, as if the Arduino board were held with the logo upright.) | |
For more information, see: http://playground.arduino.cc/Interfacing/Processing | |
*/ | |
import processing.serial.*; | |
import cc.arduino.*; | |
Arduino arduino; | |
void setup() { | |
size(470, 200); | |
// Prints out the available serial ports. | |
println(Arduino.list()); | |
// Modify this line, by changing the "0" to the index of the serial | |
// port corresponding to your Arduino board (as it appears in the list | |
// printed by the line above). | |
String[] arduinos = Arduino.list(); | |
String myArduino = "/dev/tty.usbserial-A8008kUM"; | |
arduino = new Arduino(this, myArduino, 57600); | |
// Alternatively, use the name of the serial port corresponding to your | |
// Arduino (in double-quotes), as in the following line. | |
//arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600); | |
// Set the Arduino digital pins as outputs. | |
for (int i = 0; i <= 13; i++) | |
arduino.pinMode(i, Arduino.OUTPUT); | |
} | |
int pin = 2; | |
void draw() { | |
// turn off current pin | |
arduino.digitalWrite(pin, Arduino.LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment