Hey Guys,
hope you can help me out. I run a ultrasonic sensor mit the arduino uno and control the distance of the sensor with a poti. and send the distance as a MIDI Signal to my pc into Max/Msp.
everything works fine.
then i bought a second poti to adjust the MIDI channel with it. you turn the poti and the MIDI channel is switching.
but i found out on the serial monitor that the value of the poti is jumping even if i dont touch the poti.
so the problem is that the value jumps and so does the MIDI channel -.-
i guess there could be 3 reasons.
- the poti isnt good or broken.
- something in my code is wrong
- i'm not able to put 3 things into the 5V on the Arduino Uno Board.
I have my 2 potis and the MIDI out jack pluged into the 5V of the Arduino Board. Is this too much ?
is there something i just dont get?
Here the part of my code
................
if(realTime>potiDist)
{
int sensorValue = analogRead(A1);
if( (sensorValue >= 0) && (sensorValue < 129) )
{
velocityOn(144,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 128) && (sensorValue < 257) )
{
velocityOn(145,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 256) && (sensorValue < 385) )
{
velocityOn(146,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 384) && (sensorValue < 513) )
{
velocityOn(147,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 512) && (sensorValue < 641) )
{
velocityOn(148,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 640) && (sensorValue < 769) )
{
velocityOn(149,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 768) && (sensorValue < 897) )
{
velocityOn(150,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}else if( (sensorValue > 896) && (sensorValue <= 1023) )
{
velocityOn(151,1,0);
pitchBendOn(224,0,0);
analogWrite(LEDPin,0);
}
}
else
{
int sensorValue = analogRead(A1);
if( (sensorValue >= 0) && (sensorValue < 129) )
{
analogWrite(LEDPin,80);
velocityOn(144,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 128) && (sensorValue < 257) )
{
analogWrite(LEDPin,80);
velocityOn(145,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 256) && (sensorValue < 385) )
{
analogWrite(LEDPin,80);
velocityOn(146,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 384) && (sensorValue < 513) )
{
analogWrite(LEDPin,80);
velocityOn(147,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 512) && (sensorValue < 641) )
{
analogWrite(LEDPin,80);
velocityOn(148,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 640) && (sensorValue < 769) )
{
analogWrite(LEDPin,80);
velocityOn(149,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 768) && (sensorValue < 897) )
{
analogWrite(LEDPin,80);
velocityOn(150,1,sendVal);
pitchBendOn(224,0,sendVal);
}else if( (sensorValue > 896) && (sensorValue <= 1023) )
{
analogWrite(LEDPin,80);
velocityOn(151,1,sendVal);
pitchBendOn(224,0,sendVal);
}
}
lastTime=realTime;
newVal=0;
}
}
...............
Hope someone could help me
greetings from Austria
Timo