jittery response from arduino potentiometer
i have mapped a potentiometer from the serial port which goes from 0 to 1024, and mapped it right on to the frequency of the oscillators. the sound of the knob movement is quite "stepped". i have tried the slide function, with not much improvement, and i tried changing this value to be a float rather than an integer, also with no real improvement.
Have you grounded every input that's not used ?
Check the change object.
What does the patch look like? What about your Arduino code?
Have you try smoothing
so we're looking at A4, which you can see I made a float and added the slide object. does the slide object count as 'smoothing' ? `
void setup() {
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
int sensorValue4 = analogRead(A7);
int sensorValue5 = analogRead(A6);
int sensorValue6 = analogRead(A5);
float sensorValue7 = analogRead(A4);
// print out the value you read:
Serial.print("a1 ");
Serial.println(sensorValue);
Serial.println();
Serial.print("a2 ");
Serial.println(sensorValue2);
Serial.println();
Serial.print("a3 ");
Serial.println(sensorValue3);
Serial.println();
Serial.print("a4 ");
Serial.println(sensorValue4);
Serial.println();
Serial.print("a5 ");
Serial.println(sensorValue5);
Serial.println();
Serial.print("a6 ");
Serial.println(sensorValue6);
Serial.println();
Serial.print("a7 ");
Serial.println(sensorValue7);
Serial.println();
delay(1); // delay in between reads for stability
}
`
Changing the value from the arduino to a float will not help you. The arduino sends a value between 0-1023.
Everytime you send a Serial.println() (which you're doing often in your Arduino sketch), you bang the contents of the zl group and send them out, which is not needed.
Not sure what you're doing with the 107 in the [sel] object either. That indicates that every time you send the letter 'k', you bang the zl group also.
Look at the Arduino code and patch below, based on this tutorial : http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
I assume you're using a mega or similar with more than 6 inputs, but you should get an idea from how to scale it.
Also, if you don't have all your inputs wired up (or grounded), you'll get a lot of noise.
Arduino sketch :
int inByte = 0; // incoming serial byte
void setup() {
// start serial port at 9600 bps and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB only
}
establishContact(); // send a byte to establish contact until receiver responds
}
void loop() {
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
for (int i = 0; i < 5; i++) {
Serial.print(analogRead(i));
Serial.print(",");
delay(1);
}
Serial.println(analogRead(A5));
}
}
void establishContact() {
while (Serial.available()
max patch :
SCOTT FITZGERALD suggestions are great.
here is a video that explains about zl object and arduino
hope helps
Have you actually got a noisy input? Do the values jump around or are they pretty stable? I suspect that they may be stable and this is just caused by the values jumping up between reads on the Arduino side. If this is the case then I would normally use [line] instead of [slide] to smooth the input like so (the [speedlim] just simulates a jump in values between reads!):
thanks for the replies here. i actually got a little overwhelmed by the posts about zl but i think they will help me clean up the patch in general. it turns out implementing the right line object smoothed out the knob turning, just like luke suggests.
and yes, they are a little jittery when there is no movement, so i'm sure it could be better grounded but it's working good enough for the prototype.