Using Potentiometers as "Speed factors" of rotary encoders

Hey guys,

I have a DIY project where I use rotary encoders to control the mouse of my PC , basically having one encoder for the X axis and one for the Y axis. Now I am looking to add potentiometers as factors for the rotary encoders in order to control the speed of the mouse movement.

I got the wiring done but have no idea how to get the potentiometers included in my current sketch.
Any help would be highly appreciated. I attached a picture of how I wired everything so far and below is the current sketch I use.

SKETCH:

float pulsesX, XA_SIG=0, XB_SIG=1, pulsesY, YA_SIG=0, YB_SIG=1;

void setup(){
attachInterrupt(0, XA_RISE, RISING); // Pin 2
attachInterrupt(1, XB_RISE, RISING); // Pin 3
attachInterrupt(4, YA_RISE, RISING); // Pin 19
attachInterrupt(5, YB_RISE, RISING); // Pin 18
Serial.begin(115200);
delay(100);
Serial.println(“Connected”);
}//setup

void loop(){
Serial.print(“x”);
Serial.print(pulsesX);
Serial.print(“y”);
Serial.print(pulsesY);
Serial.println(“end”);
delay(20);
}

//X-Axis

void XA_RISE(){
detachInterrupt(0);
//delay(1);
XA_SIG=1;

if(XB_SIG==0)
pulsesX++;//moving forward
if(XB_SIG==1)
pulsesX—;//moving reverse

attachInterrupt(0, XA_FALL, FALLING);
}

void XA_FALL(){
detachInterrupt(0);
//delay(1);
XA_SIG=0;

if(XB_SIG==1)
pulsesX++;//moving forward
if(XB_SIG==0)
pulsesX—;//moving reverse

attachInterrupt(0, XA_RISE, RISING);
}

void XB_RISE(){
detachInterrupt(1);
//delay(1);
XB_SIG=1;

if(XA_SIG==1)
pulsesX++;//moving forward
if(XA_SIG==0)
pulsesX—;//moving reverse

attachInterrupt(1, XB_FALL, FALLING);
}

void XB_FALL(){
detachInterrupt(1);
//delay(1);
XB_SIG=0;

if(XA_SIG==0)
pulsesX++;//moving forward
if(XA_SIG==1)
pulsesX—;//moving reverse

attachInterrupt(1, XB_RISE, RISING);
}

//Y-Axis

void YA_RISE(){
detachInterrupt(4);
//delay(1);
YA_SIG=1;

if(YB_SIG==0)
pulsesY++;//moving forward
if(YB_SIG==1)
pulsesY—;//moving reverse

attachInterrupt(4, YA_FALL, FALLING);
}

void YA_FALL(){
detachInterrupt(4);
//delay(1);
YA_SIG=0;

if(YB_SIG==1)
pulsesY++;//moving forward
if(YB_SIG==0)
pulsesY—;//moving reverse

attachInterrupt(4, YA_RISE, RISING);
}

void YB_RISE(){
detachInterrupt(5);
//delay(1);
YB_SIG=1;

if(YA_SIG==1)
pulsesY++;//moving forward
if(YA_SIG==0)
pulsesY—;//moving reverse

attachInterrupt(5, YB_FALL, FALLING);
}

void YB_FALL(){
detachInterrupt(5);
//delay(1);
YB_SIG=0;

if(YA_SIG==0)
pulsesY++;//moving forward
if(YA_SIG==1)
pulsesY—;//moving reverse

attachInterrupt(5, YB_RISE, RISING);
}

Why potentiometers? You are already familiar with rotary encoders. Why not use them for speed input? with a POT, you will need a reference voltage, and analog.Read(), but you will need to calibrate a value for each potentiometer to establish the minimum position.

The code posted, I found online. My coding skills are basically non-existing.
I'd love to use POTs as I already had some flying around.

simvid:
The code posted, I found online. My coding skills are basically non-existing.
I'd love to use POTs as I already had some flying around.

If this is a hobby project, POTs make a cheap and effective way to do it, but you will need to calibrate the min-max value for the POT. Basically, POTs have a nominal value and rough tolerance, which varies from unit to unit. The ATmega328 (UNO) has a built-in reference voltage, so you can use that, or if accuracy isn't a big deal, you can just use the nominal supply voltage. You will need to wire the POTs in on the Analog ports so you can read them. What is your overall experience with Arduino? What is your experience with electronics? How much work are you willing to put into this project?