代码之家  ›  专栏  ›  技术社区  ›  Vishesh Chanana

“上载草图时出错”Arduino

  •  1
  • Vishesh Chanana  · 技术社区  · 8 年前

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

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

    代码进行了验证,但当我试图在Arduino Uno中烧录此代码时,在它说代码使用了5%的存储空间后,我得到了以下错误。

    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
    

    请帮忙。

    2 回复  |  直到 8 年前
        1
  •  3
  •   stevieb    8 年前

    上载草图时,在上载成功之前,必须断开串行输入/输出引脚与任何设备的连接。

    Uno与用于执行草图上传的USB共享两个硬件串行插脚,因此其他任何东西都不能连接到串行插脚(0和1)。

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

        2
  •  1
  •   prudhvi    8 年前