我试图弄清楚如何随着时间的推移使 LED 变暗(时间由用户定义,我们称之为 rampUp)。我将 arduino 与 adafruit breakout PWM-Servo-Driver ( http://www.adafruit.com/products/815 ) 与库一起使用:https ://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
这个突破有 4095 步(0-4095)所以现在我的问题:
我希望能够获取一个变量( int 分钟)并将其发送到一个方法,该方法将 LED 从 0 调暗到 4095,在一段时间内以相等的光强度增加。我希望每次增加时增加 1。
那么如何在不使用 delay() 的情况下编写方法呢?
void dimLights(int rampUp){
// some code to regulate the increase of the third value in setPWM one step at a time over a period of rampUp(int in minutes)
led.setPWM(0,0,4095);
}
不想使用 delay() 的原因是因为它会暂停/停止程序的其余部分。