enter image description hereI'm trying to connect 2 potentiometer (10k) and pass their value to Hairless Midi software (For Serial to Midi Bridge) the first pot is working fine but the second pot's value keep on changing and when i move around the knob of pot1 the value of pot 2 also changes.
I have tried reading the value twice but no luck....
My code:
void setup()
{
Serial.begin(9600);
}
void loop()
{
analogRead(0);
val = analogRead(0)/8; // Divide by 8 to get range of 0-127 for midi
if (val > lastVal+1 or val < lastVal+1 )
{
MIDImessage(176,1,val);}
lastVal = val;
analogRead(2);
val2 = analogRead(2)/8; // Divide by 8 to get range of 0-127 for midi
if (val2 > lastVal2 + 1 or val2 < lastVal2 + 1 )
{
MIDImessage(176,2,val2);} // 176 = CC command, 2 = Which Control, val = value read from Potentionmeter 2
lastVal2 = val2;
//val3 = analogRead(2)/8; // Divide by 8 to get range of 0-127 for midi
//if (val3 != lastVal3)
//{
//MIDImessage(176,3,val3);} // 176 = CC command, 3 = Which Control, val = value read from Potentionmeter 3
//lastVal3 = val3;
delay(100);
}
void MIDImessage(byte command, byte data1, byte data2) //pass values out through standard Midi Command
{
Serial.write(command);
Serial.write(data1);
Serial.write(data2);
}
Connected Second pot to A0 which was earlier for Pot 1 and removed pot 1
-
What happens if you swap the two pot? That shield point to whether it’s a software or hardware problem.Gerben– Gerben03/25/2018 12:46:27Commented Mar 25, 2018 at 12:46
-
I have tried swapping the pots,changing the input pin number but still the problem persist...ronaldo– ronaldo03/25/2018 12:59:29Commented Mar 25, 2018 at 12:59
-
What is your circuit? Did you wire the pots in series maybe?Maximilian Gerhardt– Maximilian Gerhardt03/25/2018 13:04:18Commented Mar 25, 2018 at 13:04
-
Give me 5 min i will upload my circuit...ronaldo– ronaldo03/25/2018 13:10:22Commented Mar 25, 2018 at 13:10
-
1Also posted on the Arduino Forumtttapa– tttapa03/25/2018 17:26:11Commented Mar 25, 2018 at 17:26
1 Answer 1
As I was having chat with @Maxmilian Gerhardt he suggested to check the voltage of pot 2 so when I checked I was getting 0 volt So he Suggested me there may be a loose connection or something with the beadboard.
So This was a workaround :
Thnx for the help @Maxmilian Gerhardt
-
1Some of those protoboards have power rails split in the middle.gre_gor– gre_gor03/26/2018 18:00:14Commented Mar 26, 2018 at 18:00
Explore related questions
See similar questions with these tags.