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;
}
}
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.
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.
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.