oct 07
Jim
Here are a few audio libraries for the processing platform :
Aaron
Today I got two different things to happen with the eyebrow switch. I'm still using the same arduino sketch as last time with the different shades of grey. I don't see myself changing this unless I change the input device.
SimpleRead_eyebrow_RGB:
This sketch allows for the eyebrow switch to change a color displayed onscreen.
none: 0, 0, 0 (black)
left: 255, 0, 0 (red)
middle: 0, 255, 0 (blue)
right: 0, 0, 255 (green)
left + middle: 255, 255, 0 ()
left + right: 255, 0, 255 ()
middle + right 0, 255, 255 ()
all: 255, 255, 255 (white)
/**
* Simple Read
*
* Read data from the serial port and change the color of a rectangle
* when a switch connected to a Wiring or Arduino board is pressed and released.
* This example works with the Wiring / Arduino program that follows below.
*/
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(1800, 1100);
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
}
void draw()
{
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
int reds [] = {0, 255, 0, 255, 0, 255, 0, 255};
int blues [] = {0, 0, 255, 255, 0, 0, 255, 255};
int greens[] = {0, 0, 0, 0, 255, 255, 255, 255};
fill(reds[val], blues[val], greens[val]);
rect(0, 0, 1920, 1200);
}
/*
// Wiring / Arduino Code
// Code for sensing a switch status and writing the value to the serial port.
int switchPin = 4; // Switch connected to pin 4
void setup() {
pinMode(switchPin, INPUT); // Set pin 0 as an input
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (digitalRead(switchPin) == HIGH) { // If switch is ON,
Serial.print(1, BYTE); // send 1 to Processing
} else { // If the switch is not ON,
Serial.print(0, BYTE); // send 0 to Processing
}
delay(100); // Wait 100 milliseconds
}
*/
SimpleRead_eyebrow_circle_move:
Moves four circles in a mirrored pattern based on eyebrow movements.
none: stationary, no action
left: move circle (top left one) left
middle: move circle up
right: move circle right
left + middle: make circle smaller
left + right: move circle down
middle + right make circle larger
all: move circle up (to be changed to something more interesting.)
/**
* Simple Read
*
* Read data from the serial port and change the color of a rectangle
* when a switch connected to a Wiring or Arduino board is pressed and released.
* This example works with the Wiring / Arduino program that follows below.
*/
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
int speed = 10;
int pos = speed;
int neg = -speed;
int xpos = 200;
int ypos = 200;
int x_size = 100;
int y_size = 100;
int size_change = 5;
int max_size = 500;
int x_screen = 1800;
int y_screen = 1100;
void setup()
{
size(x_screen, y_screen);
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
}
void draw()
{
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
int xes [] = {0, neg, 0, 321, pos, 0, 123, 0 };
int ys [] = {0, 0, neg, 0, 0, pos, 0, pos};
if (xes[val] == 321){
if (x_size - size_change > 0){
x_size -= size_change;
y_size -= size_change;
}
}
else if(xes[val] == 123){
if (x_size < max_size){
x_size += size_change;
y_size += size_change;
}
}
else{
xpos += xes[val];
ypos += ys[val];
}
ellipse( xpos, ypos, x_size, y_size);
ellipse( (x_screen-xpos), ypos, x_size, y_size);
ellipse( xpos, (y_screen-ypos), x_size, y_size);
ellipse( (x_screen-xpos), (y_screen-ypos), x_size, y_size);
}
/*
// Wiring / Arduino Code
// Code for sensing a switch status and writing the value to the serial port.
int switchPin = 4; // Switch connected to pin 4
void setup() {
pinMode(switchPin, INPUT); // Set pin 0 as an input
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (digitalRead(switchPin) == HIGH) { // If switch is ON,
Serial.print(1, BYTE); // send 1 to Processing
} else { // If the switch is not ON,
Serial.print(0, BYTE); // send 0 to Processing
}
delay(100); // Wait 100 milliseconds
}
*/