Seems to be OK. A few "cosmetic" changes
loop()
gets called continously. Thus the while(1) { ... }
construct is totally superflous.
The brackets around the return value are not needed. http://arduino.cc/en/Reference/Return
In your main loop, instead of lots of if ( ret == n ) do something ;
use the switch
. Same functionality, code more clearly states what is happening (code readability).
void loop()
{
switch( scansw() ) { // omitted the "ret" variable, too. (Optional)
case 0: continue; break ;
case 1: DrainPitSwitchClose() ; break ; // Drain Pit Switch closed
case 2: Othercall() ; break ;
case 52: digitalWrite(13,HIGH) ; if (Counter>10) FlashBonus() ; break ;
case 21: somethingelse() ; break ;
default: Serial.println("Something wrong - impossible value") ;
} // end switch
}
Note that case
do not have to be in order, the default case is optional (but usefull); you can just call a procedure, but any sequence of statements is OK in a case (including a nested switch
) - and most importantly : remember to end each case with a break