Hi everyone,
For a college project, I have written this code however on the if statements it is giving me an expected unqualified-id before 'if' error when compiling the code and i have read through other topic posts with this problem but I just can't seem to fix it. could anyone help me out?
No, just the one that inadvertently completes the if statement.
So like
if (potValue == 512) {
forward();
}
I should point out that potValue will probably not be exactly 512 very dependably. Please put your finger on this does the same thing a bit differently:
if (potValue > 544) {
left();
}
else if (potValue < 480) {
right();
}
else {
forward();
}
I used constants and made a little area around 512 for meaning forward. You could use a manifest constant, viz:
// up top for everyone to see and change
const int DEADBAND = 32;
// then later on
if (potValue > 512 + DEADBAND) {
left();
}
else if (potValue < 512 - DEADBAND) {
right();
}
else {
forward();
}
yes i do get that potValue using an actual setup won't work like this but in this case we are asked to make it to be 512 so that is not something i can change, but other than removing the semicolons everything should be good