Reputation: 465
I am working with an addressable ribbon with Arduino. The point is to light up different parts of my ribbon at different moment. To do this, I used the function delay as below:
void un_a() //first third of ribbon length
{
for (uint16_t i = 0; i < N; i++) {
strip.setPixelColor(i, strip.Color(100,255,100));
}
strip.show();
}
void deux_a() //second third of ribbon length
{
for (uint16_t i = N; i < 2*N; i++) {
strip.setPixelColor(i, strip.Color(100,255,100));
}
strip.show();
}
void trois_a() //last third of ribbon length
{
for (uint16_t i = 2*N; i < 3*N; i++) {
strip.setPixelColor(i, strip.Color(100,255,100));
}
strip.show();
}
void wave(){
void un_a();
delay(2000);
void deux_a();
delay(2000);
void trois_a();
}
So when wave()
is called, the expected behavior is:
In reality, it just blocks and lights a part of the 1st third.
I went around again and again, I don't see what I am missing. Any clue?
Upvotes: 0
Views: 74
Reputation: 141533
void un_a();
This is a function declaration. It tells, that such symbol un_a
exists, and it is a function of type void (*)()
.
If you want to call a function, you use a expresssion statement. Notice it does not have a returned type on the beginning as in a declaration:
int a; // declaration
a = 1; // statement
un_a(); // statement, this executed the un_a function
1 + 1; // another statement, this adds 1 + 1
int func(int b); // declaration, this does nothing, just the compiler knows that a function `func` exists
int (*(*func2)(int a, int (*(*)(int arr[a]))[a]))[5]; // another declaration
(void)func2(5, (int (* (*)(int *))[5])0); // statement
Try calling the functions:
void wave(){
un_a();
delay(2000);
deux_a();
delay(2000);
trois_a();
}
Upvotes: 3