How might I use audio input volume to control LEDs (with arduino)
in
Integration and Hardware
•
2 years ago
I would like to have an LED's intensity controlled by the volume from LineIn instead of the mouseY position that I have it controlled by now. Any suggestions?
Code:
import ddf.minim.*;
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
Minim minim;
AudioInput in;
void setup()
{
size(1050, 550, P2D);
arduino = new Arduino(this, Arduino.list()[0], 57600);
//strokeWeight(0.2);
minim = new Minim(this);
minim.debugOn();
in = minim.getLineIn(Minim.STEREO, 1050);
}
void draw()
{
background(0);
stroke(#FFFFFF,random(2,255));
noFill();
smooth();
for(int i = 0; i < in.bufferSize() - 1; i++)
{
ellipse(i, height/2 + in.left.get(i)*0, i+1, 0 + in.left.get(i+1)*height);
}
if(pmouseY!=mouseY){
// if the present mouseY value is different than the previous mouse value
// output this value to pin 3
arduino.analogWrite(3,mouseY);
}
}
void stop()
{
in.close();
minim.stop();
super.stop();
}
Code:
import ddf.minim.*;
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
Minim minim;
AudioInput in;
void setup()
{
size(1050, 550, P2D);
arduino = new Arduino(this, Arduino.list()[0], 57600);
//strokeWeight(0.2);
minim = new Minim(this);
minim.debugOn();
in = minim.getLineIn(Minim.STEREO, 1050);
}
void draw()
{
background(0);
stroke(#FFFFFF,random(2,255));
noFill();
smooth();
for(int i = 0; i < in.bufferSize() - 1; i++)
{
ellipse(i, height/2 + in.left.get(i)*0, i+1, 0 + in.left.get(i+1)*height);
}
if(pmouseY!=mouseY){
// if the present mouseY value is different than the previous mouse value
// output this value to pin 3
arduino.analogWrite(3,mouseY);
}
}
void stop()
{
in.close();
minim.stop();
super.stop();
}
1