Arduino串行打印 [英] Arduino serial print

查看:122
本文介绍了Arduino串行打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起来很愚蠢,但是我真的无法弄清楚.我正在arduino uno上加载以下arduino代码:

I know this sounds really silly, but I really can't figure it out. I'm loading the following arduino code on an arduino uno:

void setup() {
    Serial.begin(9600);
    Serial.println("HELLO");
}

void loop() {
// put your main code here, to run repeatedly:
}

我正在将代码上传到板上,如果我反复打开串行监视器,则会得到不同的输出.我期待输出HELLO,有时会得到.但是我也得到如下输出:HELLHELLO或HHELLO.我还在arduino nano上加载了相同的代码,并且其行为类似.

I'm uploading the code on the board and if I open a serial monitor repeatedly, I get different outputs. I'm expecting the output HELLO, and I get that sometimes. But I also get outputs like: HELLHELLO or HHELLO. I also loaded the same code on an arduino nano and it behaves similar.

有人可以解释为什么会这样吗?这是个问题吗?

Can someone please explain why this is happening? Is this an issue?

推荐答案

这可能是由于USB到串行缓冲区仍然包含来自先前重置的数据.

This could be due to the usb to serial buffer still containing data from the previous reset.

尝试将字符串存储在 PROGMEM 中,以将字符串保留在闪存中,而不是RAM和看看是否有帮助.

Try storing the string in PROGMEM to keep the string in flash memory rather than in RAM and see if that helps.

这篇关于Arduino串行打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆