Ok, I know I have done this before. But how can I use a string in a function paramater? Just like on the first line, I want to have drive(FWD,255); and have it do that.
String CW, CCW, FWD, REV, STOP, setdir;
void drive(String dir, int howfast) //call with drive(FWD/REV/CW/CCW, 0-255) for direction and speed
{
if(dir == CW)
{
digitalWrite(leftDirPin, LOW);
digitalWrite(rightDirPin, HIGH);
analogWrite(leftSpeedPin, howfast);
analogWrite(rightSpeedPin, howfast);
gyroVoltage = 5.01; //this compensates for voltage drop to stop gyro drift
}
if(dir == CCW)
{
digitalWrite(leftDirPin, HIGH);
digitalWrite(rightDirPin, LOW);
analogWrite(leftSpeedPin, howfast);
analogWrite(rightSpeedPin, howfast);
gyroVoltage = 5.01;
}
if(dir.equals(FWD))
{
digitalWrite(leftDirPin, LOW);
digitalWrite(rightDirPin, LOW);
analogWrite(leftSpeedPin, howfast);
analogWrite(rightSpeedPin, howfast);
gyroVoltage = 5.01;
}
if(dir == REV)
{
digitalWrite(leftDirPin, LOW);
digitalWrite(rightDirPin, HIGH);
analogWrite(leftSpeedPin, howfast);
analogWrite(rightSpeedPin, howfast);
gyroVoltage = 5.01;
}
if(dir == STOP)
{
digitalWrite(leftDirPin, LOW);
digitalWrite(rightDirPin, LOW);
analogWrite(leftSpeedPin, 0);
analogWrite(rightSpeedPin, 0);
gyroVoltage = 5.00;
}
return;
}