How to compile AVR code in Arduino? -


why following code not work in arduino?

#include<avr/io.h> void setup() {     ddra = 0xff; } void loop() {     porta = 0xaa;     _delay_ms(1000);     porta = 0x55;     _delay_ms(1000); } 

i following error. "ddra not declared in scope."

as know, arduino uses avr microcontrollers, why can't use avr code in arduino boards?

user261391 has first issue code. find need include delay.h delay work.

revised example:

#include<avr/io.h> #include<avr/delay.h> void setup() {     ddrb = 0xff; } void loop() {     portb = 0xaa;     _delay_ms(1000);     portb = 0x55;     _delay_ms(1000); } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -