Arduino PWM to CV out circuit
import promidi.*;
import processing.serial.*;
int com = 0; //Comport/Serial port #
MidiIO midiIO;
Serial sOut;
PFont font;
int pit;
int vel;
void setup(){
font = loadFont("ArialMT-40.vlw");
midiIO = MidiIO.getInstance(this);
println(Serial.list());
midiIO.printDevices();
midiIO.plug(this,"getMidi",0,0);
sOut = new Serial(this, Serial.list()[com], 9600);
}
void draw(){
background(255,255,255);
textFont(font,15);
fill(0,0,0);
text("Midi Data",0,14);
textFont(font,12);
text("Note:",0,28);
text("Velo:",0,42);
textFont(font,12);
text(pit,42,28);
text(vel,42,42);
}
void getMidi(Note note){
println("Got a note!");
vel = note.getVelocity();
pit = note.getPitch();
println(vel);
//println(pit);
sOut.write(vel);
sOut.write(pit);
}
Bellow is the (now) simple code to be uploaded to the Arduino board which just reads the serial data and controls the PWM output.
/*Arduino CV. Reads note and velocity information form the serial line and outputs to PWM pin */
byte note = 0;
byte vel = 0;
int synPin = 11; //Pin # for pitch CV output
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available() >= 2 ){ //Wait untill there is enough information
Serial.println(Serial.available(),DEC);
vel = Serial.read(); //FIX ME: Implement velocity sensitivity (VCA Control)
note= Serial.read();
analogWrite(synPin,note);
}
}
Arduino Control Voltage by Dana Simmons is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
Based on a work at code.google.com.
No comments:
Post a Comment