[英]delay function on Arduino doesn't behave as expected
我正在使用Arduino的可寻址功能区。 关键是要在不同的时刻点亮功能区的不同部分。 为此,我使用了如下功能延迟:
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();
}
因此,当调用wave()
时,预期的行为是:
实际上,它只是阻挡并点亮了三分之一的一部分。
我一遍又一遍地走着,我看不到我所缺少的。 有什么线索吗?
void un_a();
这是一个函数声明 。 它un_a
存在这样的符号un_a
,并且是void (*)()
类型的函数。
如果要调用函数,请使用expression语句 。 请注意,它开头没有声明中的返回类型:
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
尝试调用函数:
void wave(){
un_a();
delay(2000);
deux_a();
delay(2000);
trois_a();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.