0

Hello i am new to stackoverflow. I have a problem

    if (brightness2 == 0 || brightness2 == 255) {
    fadeAmount2 = -fadeAmount2 ; 
  }  
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);

and

Serial.println((byte)tempC);   
  delay(1000);

the second delay affects the first and the led fade is much more slow. My question is how can I apply a delay to only one part of the code and another to another. Hope you understood what i mean. Thanks in advance.

4

2 回答 2

1

你不能。但你可以数到 33:

static int cnt = 0;

if (brightness2 == 0 || brightness2 == 255) {
    fadeAmount2 = -fadeAmount2 ; 
}

delay(30);
cnt = (cnt + 1) % 33;
if (cnt == 0) {
    Serial.println((byte)tempC);
}

这将使褪色工作像以前一样快,并且打印将在 990 毫秒内触发一次。

于 2013-04-20T20:00:05.037 回答
0

在示例中,02. 数字,有无延迟闪烁示例。您应该能够修改它以适用于您的应用程序。

于 2013-04-22T05:35:56.827 回答