another function problem

Simple example. I want a condition in my main loop to start another function - in this case the piece of art does certain things while at rest, then when a button is pushed it does its full show.

void loop() //default resting behavior { if (digitalRead(inPin)) // read the switch { do some stuff; // } else { run_main_show(); } }

void run_main_show() //run show script here { do some other stuff; }

This example is just for one button and one show, but I envision cases where I want more functions... i.e. "why not just put your code in the main loop instead of another function?" isn't the answer I'm looking for...although I suppose it may be the actual answer.

Anyway, the error I get is "'run_main_show' was not declared in this scope". Which makes some sense, but how do I make the compiler happy when calling functions?

that looks good to me, but there is probably some minor syntax error causing it to break. if you post your full code i can help you track it down.

Here is the whole thing as it sits now. At the moment all I was doing was using the LED to try calling the other function (meaning as a diagnostic indicator). My code for driving a serial servo controller, among other things, will eventually go in instead.

int ledPin = 13; // LED pin 13 int inPin = 7; // switch pin 7

void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output pinMode(inPin, INPUT); // sets the digital pin 7 as input }

void loop() //default resting behavior { if (digitalRead(inPin)) // read the arm switch { digitalWrite(ledPin, HIGH); delay (50); digitalWrite(ledPin, LOW); delay (50); } else { run_main_show(); } }

void run_main_show() //run show script here { digitalWrite(ledPin, HIGH); delay (5000); }

My guess is that the //run show script here comment is confusing the Arduino IDE when it attempts to generate prototypes for the functions in your code. Normally, in C/C++ you need to declare a function before you use it, but we didn't want to make people do this. Unfortunately, our automatic prototyper doesn't always work so well.

argh...LOL...twice now I'm doing everything right and some little weird thing gets me. BTW - Is there a way in Arduino to explicitly declare a function? Not that I need it, just curious.

Ah well, away I go. I doubt you've heard the last of me - I have to get this piece ready to go to Vienna with me Wednesday morning. Nothing like a deadline to help learn a new programming language, eh? ;D

Many thanks!