I think I just need another set of eyes here.
Simple sketch using for buttons to control two Tank Tracks.
I keep getting an error stating:
In function 'void loop()':
error: 'StateRightREV' was not declared in this scope
I think I have set it up right, My Arduino just disagrees with me.
Can someone spot where I borked this?
// Set Input pin numbers:
const int PinLeftFWD = 0; // Left Track Forward
const int PinLeftREV = 1; // Left Track Reverse
const int PinRightFWD = 2; // Right Track Forward
const int PinRightRev = 3; // Right Track Reverse
// Set Output pin numbers
const int PinDRVLeftFWD = 13; // Output Left Track Forward
const int PinDRVLeftREV = 12; // Output Left Track Reverse
const int PinDRVRightFWD = 11; // Output Right Track Forward
const int PinDRVRightREV = 10; // Output Right Track Reverse
// Set initial State
int StateLeftFWD = 0; // variable for reading the pushbutton status
int StateLeftREV = 0; // variable for reading the pushbutton status
int StateRightFWD = 0; // variable for reading the pushbutton status
int StateRightRev = 0; // variable for reading the pushbutton status
void setup() {
// initialize the button pins as an input:
pinMode(PinLeftFWD, INPUT);
pinMode(PinLeftREV, INPUT);
pinMode(PinRightFWD, INPUT);
pinMode(PinRightRev, INPUT);
// initialize the output pins:
pinMode(PinDRVLeftFWD, OUTPUT);
pinMode(PinDRVLeftREV, OUTPUT);
pinMode(PinDRVRightFWD, OUTPUT);
pinMode(PinDRVRightREV, OUTPUT);
}
void loop(){
// read the state of the pushbutton value:
StateLeftFWD = digitalRead(PinLeftFWD);
StateLeftREV = digitalRead(PinLeftREV);
StateRightFWD = digitalRead(PinRightFWD);
StateRightRev = digitalRead(PinRightRev);
// Check if button is pressed
// if it is, the Drive State is HIGH:
//** Left Track Forward **
if (StateLeftFWD == HIGH) {
// Move Left Track Forward:
digitalWrite(PinDRVLeftFWD, HIGH);
}
else {
// Stop Left Track:
digitalWrite(PinDRVLeftFWD, LOW);
}
//** Left Track Reverse **
if (StateLeftREV == HIGH) {
// Move Left Track Reverse:
digitalWrite(PinDRVLeftREV, HIGH);
}
else {
// Stop Left Track:
digitalWrite(PinDRVLeftREV, LOW);
}
//** Right Track Forward **
if (StateRightFWD == HIGH) {
// Move Right Track Forward:
digitalWrite(PinDRVRightFWD, HIGH);
}
else {
// Stop Right Track
digitalWrite(PinDRVRightFWD, LOW);
}
//** Right Track Reverse **
if (StateRightREV == HIGH) {
// Move Right Track Forward:
digitalWrite(PinDRVRightREV, HIGH);
}
else {
// Stop right Track
digitalWrite(PinDRVRightREV, LOW);
}
}