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

  • What happens if you swap the two pot? That shield point to whether it’s a software or hardware problem. – Gerben Mar 25 '18 at 12:46
  • I have tried swapping the pots,changing the input pin number but still the problem persist... – ronaldo Mar 25 '18 at 12:59
  • What is your circuit? Did you wire the pots in series maybe? – Maximilian Gerhardt Mar 25 '18 at 13:04
  • Give me 5 min i will upload my circuit... – ronaldo Mar 25 '18 at 13:10
  • 1
    Also posted on the Arduino Forum – tttapa Mar 25 '18 at 17:26
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

  • 1
    Some of those protoboards have power rails split in the middle. – gre_gor Mar 26 '18 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.