Arduino串行打印 [英] Arduino serial print

查看:55
本文介绍了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天全站免登陆