有什么方法可以运行两个循环?
在Arduino的I2C LCD的第二行中滚动文本时,我无法执行闪烁的文本。
我尝试创建和命名两个循环,但它正在执行一个任务,然后是另一个任务。
void loop(){
blinkingloop();
scrollingloop();
}
void blinkingloop(){
lcd.setCursor(3, 0);
lcd.print(staticMessage);
delay(1000);
lcd.clear();
delay(500);
}
void scrollingloop(){
scrollMessage(1, scrollingMessage, 250, totalColumns);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需编写所有代码,而不会阻塞延迟。我可以建议你使用 millis 。返回自启动以来的毫秒数的函数。
尝试类似的东西:(打印空闲内存所有 10 秒的函数)
you just have to write all you're code without blocking delay. I can suggest you to use millis . a function that return the number of milliseconds since startup.
try something like that : (a function to print free memory all 10Seconds)
我认为同时执行多个过程的唯一方法是使用多线程
检查这个项目,以LCD的示例演示
I think that the only way to do multiple processes simultaneously is by using multithreading
check this project that demonstrates it with an example of an LCD
https://create.arduino.cc/projecthub/reanimationxp/how-to-multithread-an-arduino-protothreading-tutorial-dd2c37