Hi,
I have been making a metronome recently and I have come across a very small issue, but one about efficiency of programming.
A piece of code in this metronome is the following:
Because this program is barely 1000 bytes, efficiency is not really relevant, but for future use - is their a way of writing the digitalWrites as the following? (or similar)
That's cool yep... but often it's a whole bunch of pins at the top of the code being set once-off, in which case writing a function is more trouble than the once-off coding.
But indeed a good idea for frequent use (always assuming it's the same bunch of pins needing setting)
void digitalWrite(int a, int b, int level)
{
digitalWrite(a,level);
digitalWrite(b,level);
}
void digitalWrite(int a, int b, int c, int level)
{
digitalWrite(a,level);
digitalWrite(b,level);
digitalWrite(c,level);
}
majenko:
You could create your own overloaded functions:
... but first I'd have to know what an overloaded function is 8)
I'm guessing from your example, that it's to do with having essentially the same function repeated, with the same name, and which one it invokes depends on how many parameters you throw into the pot?