Error compiling for board Arduino/Genuino Uno

Hello everybody, I am doing a Arduino project with TimerOne. I was trying to blink a yellow and red LED.

Here is my code and the schematic:

Thank you.

#include <C:\Users\elimar\Documents\Arduino\TimerOne.h>
String LEDStatus="OFF";
int YellowLED=10;
int RedLED=9;
 
void setup() 
{
  // Initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards
  pinMode(YellowLED, OUTPUT);    

  
  
  Timer1.initialize(100000); 
  Timer1.attachInterrupt( BlinkYellow ); 
  Serial.begin(9600);
}
 
void loop()
{
digitalWrite(RedLED, HIGH);
delay(1000);
digitalWrite(RedLED, LOW);
delay(1000);
}
 
void BlinkYellow()
{
if (LEDStatus=="ON"){
  digitalWrite(YellowLED,LOW);
  LEDStatus="OFF";
  return;
  }
if (LEDStatus=="OFF"){
  digitalWrite(YellowLED,HIGH);
  LEDStatus="ON";
  return;
}
}

Do you have a question?
Have you missed something out of setup ()?
Is this a bootloader problem?

No, I don't have a question, I just have an error that I don't know how to solve.
No, I don't think I missed anything in the setup().
I don't know if it is a bootloader error though.
Do you want me to send you a picture of the board?
Thanks.

And the error is . . ?

(Yes, I think you have missed something out of setup (). The question was rhetorical)

The error is :

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno

Should I send you a picture of the board?

I'd hope the error message is somewhat longer than that.

No thanks.

The whole error is:

C:\Users\elimar\Documents\Arduino\sketch_jul07f/sketch_jul07f.ino:15: undefined reference to `TimerOne::attachInterrupt(void (*)(), long)'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

You need to correctly install the TimerOne library. You might think providing the absolute path is a workaround to allow you to install libraries anywhere you like, but the Arduino IDE will only compile libraries that are installed to the correct location. You can #include .h files, but the .cpp files of the library don't get compiled, and thus you get "undefined reference" errors (because the definition is in the .cpp file).

Do this:

  • Delete C:\Users\elimar\Documents\Arduino\TimerOne.h and any other files of the library you may have dumped into the C:\Users\elimar\Documents\Arduino folder.
  • Install the library correctly, following this guide: https://www.arduino.cc/en/guide/libraries
  • Change the first line of your sketch from:
#include <C:\Users\elimar\Documents\Arduino\TimerOne.h>

to:

#include <TimerOne.h>

Thank you very much, that worked, but now I have another error:

avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Select the port of your Arduino board from the Tools > Port menu.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

Thank you so much!
It works

You're welcome. I'm glad to hear it's working now. Enjoy!
Per