Error in simple i2c wire communication code

I tried simple code in Arduino nano as below

#include <Wire.h>

void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop() {
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write("1");        // sends five bytes
  Wire.endTransmission();    // stop transmitting
  delay(500);
    Wire.beginTransmission(8); // transmit to device #8
  Wire.write("2");        // sends five bytes
  Wire.endTransmission();    // stop transmitting
  delay(500);
}

But I am getting this

Arduino: 1.8.13 (Windows 7), TD: 1.53, Board: "Arduino Nano, ATmega328P"

Sketch uses 2714 bytes (8%) of program storage space. Maximum is 30720 bytes.

Global variables use 229 bytes (11%) of dynamic memory, leaving 1819 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

An error occurred while uploading the sketch



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I don't understand it .what mean by this Error.
How to solve it??????

It means the IDE is getting no response from your Arduino. Normally this happens if you have a faulty lead or you have not selected the correct serial port.

One of these is not true...

Have you tried selecting an alternative, like "old bootloader" ?

2 Likes

1. Which Arduino is your Slave device? UNO or NANO or MEGA?
2. Show connection diagram that you have made between NANO and UNO/NANO/MRGA. Check that your connection is something similar to Fig-1 below.


Figure-1:

IDE ----> Tools ----> Board:  -----> Arduino AVR Boards ------> Arduino Nano
IDE ----> Tools -----> Processor : "ATmega328P" ----> ATmmega328P (Old Bootloader)

Yes, by " old bootloader " it solved.
My Master is nano328. Slave i s pro micro 32u4 also connected i2c oled display.