Hello,
First of all i love this site. I started with arduino when my lady bought me an arduino based 3d printer last week.
I have since gotten an UNO board and some other stuff and started learning the ways of the code.
I have designed and built some gauges and monitors for my race car and im having so much fun.
Now i have a new project i want to do. I'm making an input sensing line switcher. Basically switch two line inputs from audio devices to one output. A priority switcher is the correct name.
My test code right now just fires 4 LED's based if the audio is playing or not. 2 if it is and 2 if it is not. Im having issues with stability though. IT works except i get random 0 data in the serial monitor and it changes the led output.
Here is my code so far.
const int ledout1 = 2;
const int ledout12 = 3;
const int ledout2 = 8;
const int ledout22 = 9;
const int line1 = A0;
const int pot2 = A1;
void setup() {
// put your setup code here, to run once:
analogReference(INTERNAL);
pinMode(ledout1, OUTPUT);
pinMode(ledout12, OUTPUT);
pinMode(ledout2, OUTPUT);
pinMode(ledout22, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int line1 = analogRead(0);
int pot2 = analogRead(1);
analogRead(line1);
analogRead(pot2);
if (line1 < 70 ){ digitalWrite (ledout1, HIGH); digitalWrite(ledout12, HIGH); digitalWrite(ledout2, LOW); digitalWrite(ledout22, LOW);}
else {digitalWrite(ledout1, LOW); digitalWrite(ledout12,LOW); digitalWrite(ledout2, HIGH); digitalWrite(ledout22, HIGH);}
//float voltage = pot1 *(0.3/1023);
Serial.println(line1);
delay(1000);
I am using INTERNAL reference voltage as the line voltage varies from .05-1.1 volt.
Is there a way to have the lights turn on from only 40-60 and the other set turn on at all other values.
Or better yet is there a way to stablize the data stream. I tried a smoothing code but did not work as expected and was still jumpy. I need a 4 or 5 second delay between the data stream on the final product so that the audio doesnt switch during a song break.
Any ideas or suggestions. Thanks
}
