I don't know how much programming experience you have, so I apologize if I'm just telling you stuff you already know...
"If (func1 = 1)"
This
sets func1, it doesn't check it. A conditional check is always a double equals sign - "==".
A switch statement directly reads in a variable, then executes one of a number of commands ("cases") depending on the value of that variable. If you have a number that will be 1, 2, 3, etc. depending on where you are in the code, this may be what you want to use. If you just want to check if you've gone above or below a certain critical value, as with your gear tooth sensor, you probably want to use if-->then-->else statements.
Personally, I find if-->then-->else statements easier, so here are a few examples:
If you want to check multiple conditions at once:
Code:
if(A_ISTRUE && B_ISTRUE){
//Method 1
}//end if
will execute your method if both of the conditions are true, but not if only one is true.
Code:
if(A_ISTRUE || B_ISTRUE){
//Method 2
}//end if
will execute your method if
at least one of your conditions is true - that is, A, B, or both.
Code:
if(!A_ISTRUE){
//Method 3
}//end if
will execute your method if your condition is false.
Code:
if(A_ISTRUE){
//Do this if A is true
}//end if
else if(B_ISTRUE){
//Do this if A is false and B is true
}//end if
else{
//Do this if both A and B are false
}//end else
has three separate methods - one if A is true, one if A is false and B is true, one if both are false.