Potentiometer Programing Question

Hey just wondering, currently I am programing my robot for the soon up coming vex clean sweep (at our school, Gladstone hope to see some of you there :slight_smile: ) and I was wondering if anyone could briefly explain how to program my controller to have my basket and arm work as 1. Meaning that I want to have my arm / basket be a bob cat with the basket always leveled with channel 5.

It’s interesting that this was posted as I was working on this exact program for another project. To make this easy to program you need two potentiometers one on each each shaft directly liked to the pivot point. You also need each geared so it doesn’t back drive as programming will get harder if it does.

//the units on the pots are 1:1 so we zero them and use the error to drive the motors.

Pot1 = GetAnalogInput(1) - Offset1 // The offset should be the pot value at rest Pot1 should be the sholder
Pot2 = GetAnalogInput(2) - Offset2 // The offset should be the pot value at rest Pot2 should be the wrist

MotorOutput=(Pot1 - Pot2) / 2 //The 2 acts like a Gain value, a higher number equals less motor power.

// Add some if statements to limit MotorOutput to 127 to -127

SetPWM ( 1 , MotorOutput+127 );

MotorOutput = Pot1 - Pot2; // Pot1 Should be the sholder and 2 The wrist