Thanks for the answer.
I tried it this way with this simple code:
void setup() {
Serial.begin(115200);
}
void loop() {
dig(5, 8);
delay(1000);
}
void dig(uint16_t color1, uint16_t color2 = 0 , uint16_t color3 = 0) {
if (color1 > 2) {
Serial.print ("red = "); Serial.println (color1 );
}
if (color2 > 2) {
Serial.print ("green = "); Serial.println (color2);
}
if (color3 > 2) {
Serial.print ("blue = "); Serial.println (color3);
}
}
And in the compilation it returns this error:
"error: 'dig' was not declared in this scope
dig(5, 8);
^
exit status 1
'dig' was not declared in this scope"
But if I change the position of the "void dig" to before the "void loop" it works perfectly:
void setup() {
Serial.begin(115200);
}
void dig(uint16_t color1, uint16_t color2 = 0 , uint16_t color3 = 0) {
if (color1 > 2) {
Serial.print ("red = "); Serial.println (color1 );
}
if (color2 > 2) {
Serial.print ("green = "); Serial.println (color2);
}
if (color3 > 2) {
Serial.print ("blue = "); Serial.println (color3);
}
}
void loop() {
dig(5, 8);
delay(1000);
}
Is there any way to be able to use this "void dig" after the "void lloop" ???