Hi again!
using a LPF worked out great for controlling the synth. now i am having problems with code.. basically what i want to do is have 10 analogue inputs from photoresistors which are bombarded with lasers. as each beam is broken i would like the program to change the resistance value to the monotron... effectively creating a laser keyboard.
I wrote this bit of code that responds well, but to only one input.
see video:
int analogInPin = A2;
int analogOutPin = 9;
// put your setup code here, to run once:
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
if (sensorValue < 450){
analogWrite(analogOutPin, 400);
}
else{
analogWrite(analogOutPin, 0);
}
}
and when i tried to add another input nothing seems to respond.
this was the code i ended up with:
int analogInPin1 = A2;
int analogInPin2 = A3;
int analogOutPin = 9;
// put your setup code here, to run once:
int sensor1Value = 0; // value read from the pot
int sensor2Value = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
}
void loop() {
// read the analog in value:
sensor1Value = analogRead(analogInPin1);
if (sensor1Value < 150){
analogWrite(analogOutPin, 400);
}
{
// read the analog in value:
sensor2Value = analogRead(analogInPin2);
if (sensor2Value < 150){
analogWrite(analogOutPin, 500);
}
else{
analogWrite(analogOutPin, 0);
}
}
}
what would be the best way to structure my code so that it could listen to these multiple inputs and only have one output?
thanks in advance.