'An error occurred while uploading the sketch' 阿杜诺

'An error occurred while uploading the sketch' Arduino

我正在学习从 Arduino 的 UART 引脚接收数据。我正在使用 SPEC 气体传感器。这是我能写的最简单的代码。

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

void loop() {
  if(Serial.available()>0) {
    Serial.print(Serial.available());
  }
}

代码已验证,但是当我尝试在 Arduino Uno 中刻录此代码时,我收到以下错误,因为它说代码使用了 5% 的存储 space。

Sketch uses 1744 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 184 bytes (8%) of dynamic memory, leaving 1864 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1e
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x66
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x7e
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x06
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x86
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xf8
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x06
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x7e
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x86
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x9e
An error occurred while uploading the sketch

我在网上查看了解决方案,但他们提供了基本的答案,例如重新启动所有内容。没用。

请帮忙。

上传草图时,在上传成功之前,您必须断开串行 I/O 引脚与任何设备的连接。

Uno 与用于执行草图上传的 USB 共享两个硬件串行引脚,因此没有其他东西可以连接到串行引脚(0 和 1)。

如果我没记错的话,你只需要断开 Rx 引脚,但那是来自内存的,所以断开两者,它几乎肯定可以工作。

上传草图时检查arduino板是否设置正确configuration.such选择uno板,串口,即使你构建双向模型,当你分配SAM板时它也能工作。