I’m new to arduino. I just wrote my first shift register program but I found a hidden trap. Here is what I did:
- I defined a few pre-compile macros with #define
#define clockPin 10
- I compiled the program and it failed to compile.
Here’s the problem. I think when I did the #define, the complier replaced the clockPin in the wiring.h with 10. Here’s the original line:
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
This was a simple mistake but took me a while to realize since the complier error messages are not always to the point.
I think, since one is not required to name the arguments of a declared function until the function is actually defined, why don’t we remove those names from the above line and make it read this way?
void shiftOut(uint8_t, uint8_t, uint8_t, byte);
Is this doable with the corrent complier or are the developers leaving these names to remind themselves? Thanks. :