jtw11:
It may sound like a stupid question; but what do you mean by no parameters to main?
Clearly we have many ways in inputting things to an MCU?
When a C program is run under an OS (Linux etc.) command line parameters can be passed to the program (e.g. in "sort mylist", if the program was called "sort", the first command line parameter would be "mylist"), and in the program sort.c sees these command line parameters as parameters passed to main() (which is the "top level" function that the program starts in.)
Since you can't pass parameters to main() in an embedded application (the program just starts up at power up without any user interaction), this avenue of communication isn't open. The program, once running, can get potentially get inputs from a variety of other input sources however.
One of the "Arduinoisms" you may have just encountered is that in an Arduino sketch, you don't actually start in a main() function. (main() is actually there in the background, but hidden away from your "sketch" program.) Instead, you need to write two functions that are called by main() in the background. They are:
void setup()
{
}
and
void loop()
{
}
The main() function (that you don't see) that is calling these functions looks like this:
int main()
{
setup();
for(;;)
loop();
}
which means that the setup() function (that you write) is called once at the start of execution, but your loop function is called repeatedly after that.
jtw11:
Would anybody have any recommendations for a book aimed specifically at embedded C, rather than C used in a 'normal' PC environment? Things such as the above I fear will complicate matters, I'm never one just to accept "that's how it is" and move on, so will always want to know why things that appear to make no different to my code are there.
C in an embedded environment is a subset of C in a non-embedded environment. You read a general C book (like K&R) and just have to understand that some things just won't make sense in an embedded environment (e.g. file IO functions like fopen() etc. won't work because there is no file system for them to operate on!)
The language is the same, however (modulo some of the Arduino idiosyncracies.) In the embedded world, the equivalent to "hello world" is the "blink" program. Have a look for it in the example programs included with the Arduino IDE. Probably the most direct way forward is to be reading the Arduino example code, experimenting with it, and then referring to the K&R to understand the C language constructs they employ.
I suspect you will make rapid progress.