Libhart, thank you for your in-depth response. I took up your suggestion and replaced the flashLedActive Function with your version. However, after compiling I got an error - "To many arguments passed ..." Looking at it, we aren't passing anything at all so I tried forcing just one argument - an integer. so my code looks like this:
void flashLedActive(int) {
// code contained in a function to turn flashLedPin on and off using code below
digitalWrite(yellowLedPin, HIGH); // turn on the yellow LED
for (int i=0; i<4; i++)
{
digitalWrite(flashPin, !digitalRead(flashPin));
delay(1000);
}
return;
}
It compiles correctly! Why did I have to pass it the int argument? Also I now see what you mean about passing flashMe back to the Function - it isn't required since it is declared earlier. My understanding of how to setup a Function is now much clearer thank you. I guess my interest in containing my code in "globally available functions" is to make my code more modular and re-usable. Instead of having to sift through many lines of code replacing Variable Values, I know they are defined once inside a Function. This must make it easier to find bugs as well. So I can't understand why this would be viewed as a hack method of declaring variables unless it uses up more memory, slows things down etc? - Maybe this project isn't the most ideal example of how to illustrate the proper use of Functions? My aim was to discover how I could re-use the one push button to perform more then just a single task. Using Functions seemed the right way to go.