Question about the differences between AVR and Arduino code instructions

Thread Starter


Joined May 11, 2017

I am new with micro controllers. I would like to know if we can use the same exact C code from an Arduino to program an AVR micro controller from AVR Studio? Do they use the same C language instructions in their ‘’Studio sofware’’ ? If not, how much different are the code instructions between those 2?

Thank you


Joined Aug 7, 2017
AVR-GCC lacks the libraries that arduino has. However you can program a non-arduino microcontroller by arduino IDE with some tweaks.


Joined Aug 21, 2008
Not exactly. You can program an AVR with the hex file complied under Arduino as long as it is the same kind of AVR controller targeted by the origional program.


Joined Jul 5, 2008
Kind of funny but atmel studio The latest one lets you import arduino code.

But you can use arduino without the cores and code just as you would with avr-gcc=4.9.2

Like this
/* Arduino Uno Blink sketch for use with the empty core */

#include <avr/io.h>
#include <stdint.h>

int led = 5; // In port B

void setup() {               
DDRB = DDRB | 1<<led;         // Define PB5 as an output

volatile long Counter;

void delay (long n) {          // Delay by n milliseconds
Counter = 469 * n;
  do Counter--; while (Counter != 0);

// The loop routine runs over and over again forever:
void loop() {
  PORTB = PORTB | 1<<led;      // Take PB5 high
  delay(1000);                 // Wait for a second
  PORTB = PORTB & ~(1<<led);   // Take PB5 low
  delay(1000);                 // Wait for a second

// We need main()
int main() {
  for(;;) loop();


Joined Aug 17, 2017
that's good to know about atmel studio. .

One point to remember, each library will need to be inspected to see if it will work on the target avr. Probably most will be fine with maybe some pin redefinitions but some may need significant rework.

It would be wonderful if there was an arduino "core generator". Especially for the ARM chips...