2. März 2013
Compo3000 ist ein haptisches Kompositionstool. An der Schnur können verschiedene Kügelchen platziert werden. Zieht man an der Schnur, wird diese eingezogen. Jedes mal wenn eine Kugel im Compo verschwindet ertönt ein Klang. Das ganze könnte man auf mehrere Schnüre Skalieren. So, dass man Notenlinien bespielen könnte.
![cut_compo_b](../../../../files/2013/03/cut_compo_b.jpg)
compo3000_final_cut_hoch [Konvertiert] compo3000_final_cut_breit [Konvertiert]
compo processing code
import themidibus.*;
MidiBus myBus; // The MidiBus
import processing.serial.*; // Import the Processing Serial Library for communicating with arduino
Serial myPort; // The used Serial Port
int lichtWert; // fourthValue, fifthValue, ... // add more if needed
boolean firstPlay = false;
int channel = 1;
int pitch = 100;
int velocity = 200;
int lichtKugel = 20;
int lichtSchnur = 30;
void setup()
{
size(500, 500);
println(Serial.list()); // Prints the list of serial available devices (Arduino should be on top of the list)
myPort = new Serial(this, Serial.list()[0], 9600); // Open a new port and connect with Arduino at 9600 baud
myBus = new MidiBus(this, -1, "Java Sound Synthesizer"); // Create a new MidiBus with no input device and the default Java Sound Synthesizer as the output device.
}
void draw()
{
println(lichtWert);
if (lichtWert < lichtKugel && firstPlay == false)//lichtwert bei kugel innen
{
myBus.sendNoteOn(channel, pitch++, velocity); // Send a Midi noteOn
delay(200);
myBus.sendNoteOff(channel, pitch, velocity); // Send a Midi nodeOff
firstPlay = true;
}
if (lichtWert>lichtSchnur)
{
firstPlay = false;
}
}
void serialEvent(Serial myPort) // Is called everytime there is new data to read
{
if (myPort.available() > 0)
{
String completeString = myPort.readStringUntil(10); // Read the Serial port until there is a linefeed/carriage return
if (completeString != null) // If there is valid data insode the String
{
trim(completeString); // Remove whitespace characters at the beginning and end of the string
String seperateValues[] = split(completeString, ","); // Split the string everytime a delimiter is received
lichtWert = int(seperateValues[0]);
}
}
}
_
compo arduino code
/*
Stepper Motor Control with a pull-switch
+ triggering sounds with a light sensor through mulab
Oliver Kalbermatter 20fucking13
*/
//sensor-sound part
#define FIRST_PIN A5 // Define the Analog Pins add more if needed
#define SECOND_PIN 1
//servo part
int stepCounter = 0; // Counter zurücksetzen
int cancelCounter = 20; // länge des Einzugs
boolean motorMove = 0;
const int switchPin = 2; // the number of the pushbutton pin
#include <Stepper.h>
int switchState = 0; // variable for reading the pushbutto
int lastswitchState = HIGH;
int firstValue; //secondValue; // Define Variables to store the analog Values
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);
//
void setup() {
Serial.begin(9600); //Open the Serial Port with baudrate set to 9600 (talk to processing)
pinMode(switchPin, INPUT);
// set the speed at 60 rpm:
myStepper.setSpeed(20);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
//sound-sensor part
firstValue = analogRead(FIRST_PIN); // Read the first PIN
//secondValue = analogRead(SECOND_PIN); // Read the second PIN
Serial.print(firstValue); // Send the first Value
Serial.print(','); // Send a delimiter
// Serial.print(secondValue); // Send second Value
//Serial.print(','); // Send a delimiter
Serial.println(); // Send a carriage-return
//servo part
switchState = digitalRead(switchPin);//switchState wird mit den Werten vom Pin geladen (High/Low)
if (switchState != lastswitchState)
{
Serial.println("switching"); //der switch wurde betätigt
motorMove = true; // stepper aktivieren
}
if (motorMove == true);
{
if(stepCounter < cancelCounter)
{
myStepper.step(1);
stepCounter ++;
}
else
{
Serial.println("stopping");// die Spule hält an
stepCounter = 0;
motorMove = false;
}
}
lastswitchState = switchState;
}