I wrote a code where the amplitude of a audio input is mapped to the amplitude of a sin function. Right now is just controlling the position of ellipse on a screen but i want this motion to be applied to a drawing machine using an Arduino, possibly a servo motor.
does any one have an example of how to convert this to using a motor?
import processing.sound.*;
Amplitude amp;
AudioIn in;
float s;//s is a map of the analyzer
float c;
float p;
float e;//speed
float range;
float v; //vertical movement
void setup(){
size(1000,1000);
amp = new Amplitude(this);
in = new AudioIn(this, 0);
in.start();
amp.input(in);
colorMode(HSB,360,100,100);
s=0;
e=0;
v=0;
background(c,100,100);
noStroke();
}
void draw(){
range=map(amp.analyze(),0,1,500,1500);
e=e+1;
p=map(sin(e),0,1,500,range);
//c=map(amp.analyze(),0,.5,0,360);
ellipse(p,v,5,5);
// s=map(amp.analyze(),0,1,100,800);
v=v+.1;
}