the position determined by the pressure sensors would produce a chord of audio (three synthesized notes) from the speakers around the room at a modest volume. once a viewer speaks into the microphone the frequency data will be used to make “chords” of light (three lighted bands) with the LED bands around the room (ultimately the viewer is intended to “sing” into the microphone, only simple humming would be necessary & would likely be encouraged by the audio from the room speakers).
my mock-up consists of a flex-sensitive resistor giving input for an LED array, producing “chords” of light, & a potentiometer producing a range of colors from an RGB LED. code after the picture:
/* project 1 - analog in/analog out */
int potPin = 2; // select the input pin for the potentiometer (powered 5V)
int flexPin = 0; // select the input pin for the FSR (powered 3.3V)
int bPin = 11; // select the pin for the RGB LED & LED array
int gPin = 10;
int rPin = 9;
int aPin1 = 3;
int aPin2 = 5;
int aPin3 = 6;
int val = 0; // variable to store the value coming from the sensors
int B = 0; // variables for output
int G = 0;
int R = 0;
int a1 = 0;
int a2 = 0;
int a3 = 0;
int inB = 0; //variables to prevent the code from being super buggy
int inG = 0;
int inR = 0;
int in1 = 0;
int in2 = 0;
int in3 = 0;
void setup() {
pinMode(bPin, OUTPUT); // declare the led pins as OUTPUT
pinMode(gPin, OUTPUT);
pinMode(rPin, OUTPUT);
pinMode(aPin1, OUTPUT);
pinMode(aPin2, OUTPUT);
pinMode(aPin3, OUTPUT);
Serial.begin(9600); // diagnostic printout
}
void loop() {
val = analogRead(flexPin); // read the value from the sensor, set to diagnostic variable
in1 = analogRead(flexPin);
in2 = analogRead(flexPin);
in3 = analogRead(flexPin);
if(in1 <= 250) // LED 1 on array a1 = 0; if(in1 > 250 && in1 <= 375) a1 = map(in1, 251, 375, 0, 255); if(in1 > 375 && in1 <= 625) a1 = 255; if(in1 > 625)
a1 = map(in1, 626, 750, 255, 0);
if(in2 <= 125) // LED 2 on array a2 = map(in2, 0, 125, 0, 255); if(in2 > 125 && in2 <= 375) a2 = 255; if(in2 > 375 && in2 <= 500) a2 = map(in2, 376, 500, 255, 0); if(in2 > 500)
a2 = 0;
if(in3 <= 125) // LED 3 on array a3 = 255; if(in3 > 125 && in2 <= 250) a3 = map(in3, 126, 250, 255, 0); if(in3 > 250 && in3 <= 500) a3 = 0; if(in3 > 500 && in3 <= 625) a3 = map(in3, 501, 625, 0, 255); if(in3 > 625)
a3 = 255;
analogWrite(aPin1, a1);
analogWrite(aPin2, a2);
analogWrite(aPin3, a3);
inB = analogRead(potPin); // set value to RGB variables
inG = analogRead(potPin);
inR = analogRead(potPin);
if(inB <= 340) // BLUE LED B = 0; if(inB > 340 && inB <= 510) B = map(inB, 341, 510, 0, 255); if(inB > 510 && inB <= 850) B = 255; if(inB > 850)
B = map(inB, 851, 1023, 255, 0);
if(inG <= 170) // GREEN LED G = map(inG, 0, 170, 0, 255); if(inG > 170 && inG <= 510) G = 255; if(inG > 510 && inG <= 680) G = map(inG, 511, 680, 255, 0); if(inG > 680)
G = 0;
if(inR <= 170) // RED LED R = 255; if(inR > 170 && inR <= 340) R = map(inR, 171, 340, 255, 0); if(inR > 340 && inR <= 680) R = 0; if(inR > 680 && inR <= 850) R = map(inR, 681, 850, 0, 255); if(inR > 850)
R = 255;
analogWrite(bPin, B); // output RGB values to RGB pins
analogWrite(gPin, G);
analogWrite(rPin, R);
Serial.println(val); //diagnostic printout
}