Include avr library in my sketch

Hi all,

I am completely newbie in this and I am having problem trying to include avr libraries/header files especially avr/io.h in my sketch. The IDE says fatal error, no such file or directory.

The reason why I need this library is because I found a piece code online that uses functions and predefined variables such as ADMUX, _BV(), ADCSRA and ADSC

My Arduino IDE is under Windows 8.1 environment and I understand that avr library is in the path Arduino/hardware/tools/avr/avr/include/avr It seems that I can't add any file from this path.

I read about how library under tools folder can't be added because they are not under core folder, so I tried to copy and paste the avr library into sketchbook/libraries and it didn't work.

Can someone show me how do I include files such as avr/io.h in my code? Thanks.

F33d

"avr/io.h" is automatically linked via the IDE. I believe it is included in the wiring.h file.

add a line like this at the top of your sketch:

#include <avr/eeprom.h>

Hi JimEli,

Thanks for your reply. I will give it a try.

F33d

Feedorafk:
I will give it a try.

Be sure that the board setting in the IDE is correct, before you try direct port and register programming!

After you have set the board correctly, let's say to "Arduino UNO", the IDE will automatically know about alle the input and output ports, timers and interrupts that are available on an Atmega328 which is the controller used an an Arduino UNO.

It's still not letting me include avr/eeprom.h with the same error message. But thanks for giving me this hint, I will try and look for other .h files that might have avr/io.h in it.

Thanks

jurs:
Be sure that the board setting in the IDE is correct, before you try direct port and register programming!

After you have set the board correctly, let's say to "Arduino UNO", the IDE will automatically know about alle the input and output ports, timers and interrupts that are available on an Atmega328 which is the controller used an an Arduino UNO.

Hi jurs,

I was being stupid as the board selection was on Arduino Due. Thanks so much for pointing it out. Now it works just fine. Thanks for the help. Now I can finally kick off with the rest of the code.

F33d