- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
/*
arduino_output
Controlls arduino via Firmdata protocol
*/
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
PFont font;
color off = color(4, 79, 111);
color on = color(84, 145, 158);
int[] modes = { Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT,
Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT,
Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT, Arduino.OUTPUT };
int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW };
int[] pwms = { 100,100,100,100, 100,100,100,100,100, 100,100,100,100,100 };
void setup() {
size(470, 340);
font = createFont("Arial", 16, true);
// 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).
arduino = new Arduino(this, Arduino.list()[2], 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, modes[i]);
}
void draw() {
background(off);
stroke(on);
// Titles & Authors
textAlign(LEFT);
text("Arduino GUI Controller v0.1", 5, 335);
textAlign(RIGHT);
text("by Jonathan Rosewood", 465, 335);
// Buttons
noFill();
textAlign(CENTER);
rect(360, 90, 80, 30);
text("DEFAULT", 400, 110);
rect(360, 130, 80, 30);
text("REBOOT", 400, 150);
// Digital pins
for (int i = 0; i <= 13; i++) {
// Draw lables
fill(on);
textAlign(CENTER);
text(str(i), 430 - i * 30, 20);
// Draw pins
if (modes[i] == Arduino.OUTPUT) {
if (values[i] == Arduino.HIGH)
fill(on);
else
fill(off);
} else {
if (arduino.digitalRead(i) == Arduino.HIGH)
fill(on);
else
fill(off);
}
rect(420 - i * 30, 30, 20, 20);
// Draw modes
fill(on);
textAlign(CENTER);
if (modes[i] == Arduino.OUTPUT)
text("O", 431 - i * 30, 75);
else
text("I", 431 - i * 30, 75);
noFill();
rect(420 - i * 30, 60, 20, 20);
// Draw PWM bars
noFill();
if(i == 3 || i == 5 || i == 6 || i == 9 || i == 10 || i == 11) {
rect(420 - i * 30, 90, 20, 100);