I am working on a project to use 3 POT to operate two motors using a Arduino and a Arduino Motor Shield
The Joystick I have has 3 POT
POT voltage Outputs:
Y POT: in Center Position reads 2.4 VDC, All the way forward reads 1.5 VDC, all the way backwards reads 3.5 VDC
+X POT: in Center Position reads 1.5 VDC, All the way to the right reads 3.5 VDC
-X POT: in Center Position reads 1.5 VDC, All the way to the Left reads 3.5 VDC
The Y axis is to drive both motors forward or backwards. As of now I have a Scratch that will perform this action
The X axis is to resist one motor from the other; that way I can turn the project left or right as the joystick gets moved left or right. if the joystick is moved forward the project will move forward (straight) but during the forward of the joystick if the operator moves the stick left or right it will turn the project.
Below is what I have already....need help on how to configure the scratch for the other two POTs, also the max output mA to the motors needs to be 100mA
Thanks
*/
int rightBrake=9;
int leftBrake=8;
int readPin=A2;
int readVal;
float V2=0;
void setup() {
pinMode(readPin,INPUT);
pinMode(rightBrake,OUTPUT);
pinMode(leftBrake,OUTPUT);
pinMode(12,OUTPUT); //Channel A Direction Pin Initialize
pinMode(13,OUTPUT); //Channel B Direction Pin Initialize
Serial.begin(9600);
}
void loop() {
if (analogRead(readPin) > 512)
{
readVal=analogRead(readPin);
V2=(5./1023.)readVal;
digitalWrite(rightBrake,LOW);
digitalWrite(leftBrake,LOW);
digitalWrite(13, LOW); //Channel B Direction Reverse
analogWrite(11, 0.5analogRead(readPin)-255); //Channel B Speed
digitalWrite(12, HIGH); //Channel A Direction Reverse
analogWrite(3, 0.5*analogRead(readPin)-255); //Channel A Speed
int sensorValue = analogRead(readPin);
Serial.println(V2);
delay(150);
}
if(analogRead(readPin) < 505)
{
readVal=analogRead(readPin);
V2=(5./1023.)readVal;
digitalWrite(rightBrake,LOW);
digitalWrite(leftBrake,LOW);
digitalWrite(13, HIGH); //Channel B Direction Forward
analogWrite(11, 255-0.5analogRead(readPin)); //Channel B Speed
digitalWrite(12, LOW); //Channel A Direction Forward
analogWrite(3, 255-0.5*analogRead(readPin)); //Channel A Speed
int sensorValue = analogRead(readPin);
Serial.println(V2);
delay(150);
}
}