0

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

asked Mar 25, 2018 at 12:44
13
  • What happens if you swap the two pot? That shield point to whether it’s a software or hardware problem. Commented Mar 25, 2018 at 12:46
  • I have tried swapping the pots,changing the input pin number but still the problem persist... Commented Mar 25, 2018 at 12:59
  • What is your circuit? Did you wire the pots in series maybe? Commented Mar 25, 2018 at 13:04
  • Give me 5 min i will upload my circuit... Commented Mar 25, 2018 at 13:10
  • 1
    Also posted on the Arduino Forum Commented Mar 25, 2018 at 17:26

1 Answer 1

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 :

enter image description here

Thnx for the help @Maxmilian Gerhardt

answered Mar 25, 2018 at 16:11
1
  • 1
    Some of those protoboards have power rails split in the middle. Commented Mar 26, 2018 at 18:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.