I am attempting to create a motorized rotary potentiometer connected to max/MSP for recall of parameters. I have gotten one potentiometer to work, but when I try it with two one of the pots controls the other. Max is not reading the information for both Voltages separately. Attached are my patches and circuit.
The Alps pot pins are labeled, left to right: Dummy|A-read|GND|5v|A-read|GND|5v|Dummy Here is a video showing how it works.
Here is the Max/MSP patch: MAX/MSP Patch
and here is the code for one potentiometer:
const int servoPos=7;
const int servoNeg=8;
float potVolt = A1;
void setup(){
Serial.begin(9600);
pinMode(servoPos, OUTPUT);
pinMode(servoNeg, OUTPUT);
}
void loop(){
byte positive;
float potVolt = analogRead(A1)/ 4;
if (Serial.available()) {
positive = Serial.read();
//threshold of +/- 1.5 so pot doesn't bounce around
if (potVolt > (positive + 1.5)) {
digitalWrite(servoPos, LOW);
digitalWrite(servoNeg, HIGH);
}
else if (potVolt < (positive - 1.5)) {
digitalWrite(servoPos, HIGH);
digitalWrite(servoNeg, LOW);
}
if (potVolt == positive) {
digitalWrite(servoNeg, LOW);
digitalWrite(servoPos, LOW);
}
}
Serial.print(positive);
Serial.print(" ");
Serial.println(potVolt);
}
Attached here is the code for ONE POT and TWO POTS that I attempted as well.
The ONE POT (POTS_SERIAL.ino) works. 2alps_serial.ino doesn't.
How are you sending the values to the Arduino? I suspect everytime you send a value it is going into the variable pot1.
You almost certainly need a more sophisticated system for receiving data. Either ALWAYS send two bytes at a time OR have some system to tell the Arduino which variable the byte is intended for.
Also you use if Serial.available() which only guarantees the availability of 1 byte even though you REQUIRE two bytes.
Put in some Serial.print() statements so you can see how your program is actually working.
Hi, I am sorry but I have no idea what your fizzing diagram is showing, that is the geared thing that the two arduino outputs 7 and 8 go to?
What is the knob representing and what area all the red and black wires doing?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
But not a fitzle diagram.
Show how it is powered and all your connections, if you are serious about this project, then a circuit diagram is essential when it comes to seeking help as well as helping yourself.
The Alps potentiometers have the motor built into it already. I just used 123dcircuits.com to create the diagram, and they didn't have a pot coupled with a motor so I just placed them both in independently. 7 and 8 are what turn the motor either clockwise or counter clockwise. If my voltage is read as a number lower than what my input (in max/msp) is, then the pot will turn up, causing the voltage to rise and (reading it in max/msp) shut off the motor once the voltage matches my integer.
I stated in the OP,
The Alps pot pins are labeled, left to right: Dummy|A-read|GND|5v|A-read|GND|5v|Dummy
Robin2:
How are you sending the values to the Arduino? I suspect everytime you send a value it is going into the variable pot1.
I'm using the serial between Max/MSP and Arduino. When I look at the Serial Monitor in the IDE it reads both of the voltages and continually scrolls, so I know it's sending two, but in max/MSP it's only receiving the voltages in one of the integer objects, and interpolating between them.
Tom,
I don't know how to make a circuit diagram, I'm new to this. I'm plugging the arduino into the computer via usb... the diagram I made shows the positive pins connected to the 5v pin. Again, the serial monitor is reading the voltages separately, it's not sending to max properly though. Everything on the hardware side is connected properly and runs fine. The issue is when I use the code for two pots, max is reading them on only one integer object.
This is my first post on here so I'm sorry if I'm a little unorganized, and I'm just a noob with Arduino and Max. Thanks for the help though, I appreciate everything!
The problem here is not many people have MAX due to its cost, I know that is why I don't have it at the moment. So can you post a screen dump of your patch so we can see how you are distinguishing between the two values you are sending.
That worked in allowing max to read both of the voltages separately!! Thanks. Now I have to figure out how to send the data back to the arduino as multiple integers because it's now reading the feedback data as an interpolating integer >.<