使用Serial.print奇怪的初始输出 [英] Strange initial output using Serial.print

查看:559
本文介绍了使用Serial.print奇怪的初始输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写的串行接口,我越来越陌生和意外的输出,当我第一次素描运行。输出似乎是什么应该打印的变体:

When I'm writing to the serial interface, I'm getting strange and unexpected output when my sketches first run. The output seems to be a variant of what should be printed:

例如:

String text1 = "foobar";

void setup() {
  Serial.begin(9600);

  Serial.print("\n");
  Serial.print(text1);
}

void loop() {
}

结果输出:

fo
foobar

(之前的FO,但我不能工作了如何将它出现在新行)。

(the new line appears before "fo" but I couldn't work out how to include it).

所以,无论是应该被印刷的一些变型中,被认为是应该要打印的实际文本之前打印。改变输出,改变了文本异常(有时它会是两个字,有时三)。使得不影响输出和重新编译的变化对反常文本没有影响

So some variant of whatever is supposed to be printed, gets printed before the actual text that is supposed to be printed. Changing the output, changes the anomalous text (sometimes it'll be two characters, sometimes three). Making changes that don't affect the output and recompiling has no effect on the anomalous text.

我是一个总的Arduino新手(我只是今天开始写我自己的code),但我只能认为这是不正常的。
我使用的是Freetronics EtherTen和1.0 IDE

I'm a total Arduino newbie (I only started writing my own code today), but I can only assume this isn't normal. I'm using a Freetronics EtherTen and the 1.0 IDE

在此先感谢

推荐答案

这是最有可能的串行通信复位问题,因为叶兰W¯¯指出。看到我的previous答案这里

This is most likely a Serial communication Reset issue as Eran W pointed out. See my previous answer here.

当它接收来自除Arduino的IDE其他大部分事情串行通讯Arduino的自动复位。这就是为什么你可以从IDE发送,但不是别的。

The Arduino automatically resets when it receives serial communication from most things other than the Arduino IDE. This is why you can send from the IDE but not anything else.

我有一个乌诺,把复位和Ground.Here的关于这个问题的一些好的信息页面之间的电容器。结果
祝你好运。 http://arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

I have an Uno and put a capacitor between Reset and Ground.Here's a page with some good info on the subject.
Good luck. http://arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

这篇关于使用Serial.print奇怪的初始输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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