I am trying to get IDE to compile a simple serial com code for Nano, but, I am running into compile error. can't understand what/why. can anyone help please?
code:
// Nano (Sender) Code
#define LED_PIN 13 // Status LED on Nano
void setup() {
Serial.begin(9600); // Initialize Serial Communication
pinMode(LED_PIN, OUTPUT);
}
void loop() {
Serial.println("LED_ON"); // Send command to Mega
digitalWrite(LED_PIN, HIGH);
delay(2000); // Wait 2 seconds
Serial.println("LED_OFF"); // Send command to Mega
digitalWrite(LED_PIN, LOW);
delay(2000); // Wait 2 seconds
}
error:
C:\Users\ADMIN\AppData\Local\Temp\cc9BbG0G.ltrans0.ltrans.o:(.rodata+0x6): undefined reference to Print::write(unsigned char const*, unsigned int)' c:/users/admin/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to main'
collect2.exe: error: ld returned 1 exit status
I moved your topic to an appropriate forum category @siv-ide .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
Hi @siv-ide. Which version of Arduino IDE are you using (e.g., "2.0.1")? The version is shown on the window title bar and also in the dialog that opens when you select Help > About (or Arduino IDE > About Arduino IDE for macOS users) from the Arduino IDE menus.
I ask for this information because I want to give you the appropriate instructions for the IDE version you are using.
This more than likely indicates that you have a corrupt installation. Is this the first time that you try to use the IDE?
I would suggest to downgrade the AVR board package (it should be 1.8.6 currently) to e.g. 1.8.3 using the board manager and try again. If that works, you can upgrade to 1.8.6 again.
No, ive used this IDE countless times before and have compled and downloded onto other boards (UNO/MEGA/MEGA 2560 mini Pro/ and even Nano classic etc). Had no issues then.
Since this issue first appeared, I've reinstalled this IDE twice now and installed it again. Did this on via windows uninstall add/remove etc etc. Windows operating sysetm is Win 10.
So it used to work for all AVR based boards. Select another board (e.g. Mega) and compile (no need to upload).
Create an empty sketch; save it as something (!!) and compile. Does the compile still fail?
Did you try the downgrade/upgrade as suggested?
Another step to solve the issue could be to clear the cache in C:\Users\yourUsername\AppData\Local\arduino.
It has a "copy" of your code; it's safe to delete (I do it quite often). If you're familiar with other IDEs for software development they usually have an option to do a clean build; clearing the cache has the same effect.
In IDE 1.8.x the cache (it's an other directory) is cleared when you close the IDE.