1

I am learning to receive data from the UART pins of the Arduino. I am using a SPEC Gas Sensor for the same. Here is the simplest code I could write.

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

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

The code verifies but when I try to burn this code in the Arduino Uno, I get the following error after it says that the code uses 5% of the storage 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 checked online for a solution but they provide basic answers like restarting everything. It doesn't work.

Please help.

0

2 Answers 2

3

When uploading a sketch, you must disconnect the serial I/O pins from any devices before an upload succeeds.

The Uno shares the two hardware serial pins with the USB that's used to perform sketch upload, so nothing else can be connected to the serial pins (0 and 1).

If I recall correctly, you only need to disconnect the Rx pin, but that's from memory, so disconnect both and it'll almost certainly work.

Sign up to request clarification or add additional context in comments.

Comments

1

When uploading a sketch check whether arduino board was set into correct configuration.such as selecting the uno board ,serial port ,even when you constructing a model of bidirectional it work when u assign the SAM board.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.