I wrote a differential steering program...maybe it could be useful to you

I wrote this differential steering program for myself, but I thought it might be useful to someone else. I'm still kind of a beginner, so there is probably a more efficient way, but here it is:

const int potmin = 26; //your pot turned all the way down
const int potmax = 1023; //your pot turned all the way up
int potin; // this is where the input from pot 1 will be stored
int potmapped;// the pot brought down to a value that will work with our outputs
const int potmin2 = 26;//the same things for pot 2
const int potmax2 = 1023;
int potin2;
int potmapped2;
int left;
int right;
const int pot = A0;// the pin numbers for the inputs and outputs
const int pot2 = A1;
const int leftoutput = 11;
const int rightoutput = 10;
const int maxspeed = 255; //If you want to restrict the speed for some reason, put your max speed here.

void setup() {
  // put your setup code here, to run once:
  pinMode(pot, INPUT);// set up the inputs and outputs
  pinMode(pot2, INPUT);
  pinMode(leftoutput, OUTPUT);
  pinMode(rightoutput, OUTPUT);


void loop() {
  // put your main code here, to run repeatedly:
potin2 = analogRead(A1);//Get data from
potin = analogRead(A0);//the pots
potmapped2 = map(potin2, potmin2, potmax2, 0, 255);// constrain it to a usable number in this program
potmapped = map(potin, potmin, potmax, 0, 510);
left = constrain(map(potmapped , 0, 510, 0,potmapped2), 0, maxspeed);//map the left and right outputs depending on the steering and max speed
right = constrain(map(510 - potmapped, 0, 510, 0,potmapped2), 0, maxspeed);
analogWrite(leftoutput, left);
analogWrite(rightoutput, right);



Steering.ino (1.39 KB)