Sign In

Comparison Between Arduino And Atmega32

suraj singh surajsd1701@gmail.com India

Hardware: Atmega32 And Arduino Mini Software: Embedded C ( AVR Studio)

I've written a program in Embedded C for Atmega32.
But I wanted to ask if the same code would work for Arduino mini too?
This is the link of the Arduino Board I want to use :- https://www.arduino.cc/en/Main/ArduinoBoardProMini

And if not, Then what modifications we need to undertake?

Images

Program

#include<avr/io.h>
#include<util/delay.h>
int a[8]={1,2,3,4,5,6,7,8};
int i,k,j,y=0,z=0;
void num(unsigned int p)
{
unsigned int k,w,b=1;
k=p;
while(k>=10)
{
b=b*10;
k=k/10;
}
while(b>0)
{
w=p/b;
p=p%b;
b=b/10;
dat(w+48);
}
}
void string(unsigned char *p)
{
while(*p!='')
{
dat(*p);
p++;
_delay_ms(100);
}
}
void cmd(char c)
{
PORTD=c;
PORTC=0X04;//Enable is on in read only type nothing is being written just no more data taken
_delay_ms(10);
PORTC=0X00;// Enable turned off more data taken
}
void dat(char c)
{
PORTD=c;//data to be written on the LCD
PORTC=0X05;//i-e 'Enable'is 1 and RS is 1 the already taken up input is written on the address and no more input is taken
_delay_ms(10);
PORTC=0X01;// Enable port is available for more input
} 

void lcd()//just for initializing the LCD.
{
cmd(0X38);
_delay_ms(10);
cmd(0X01);
_delay_ms(10);
cmd(0X0E);
_delay_ms(10);
cmd(0X80);
_delay_ms(10);
}
void main()
{
DDRA=0X00;
DDRC=0XFF;
DDRD=0XFF;
lcd();
string("OBSTACLE DETECT");
_delay_ms(2000);
lcd();
while(1)
{

if((PINA==0X01))
{
string("OBSTACLE DETECT");
cmd(0Xc0);
string("ST");
_delay_ms(2000);
lcd();
while((PINA&(1<<PA0)==0X01));
}
if((PINA==0X02))
{
string("OBSTACLE DETECT");
cmd(0Xc5);
string("ST");
_delay_ms(2000);
lcd();
while((PINA&(1<<PA1)==0X02));
}
if((PINA==0X04))
{
string("OBSTACLE DETECT");
cmd(0Xc9);
string("ST");
_delay_ms(2000);
lcd();
while((PINA&(1<<PA2)==0X04));
}

}
}

Post a reply to suraj singh

Think you can help suraj singh ? Then post your thoughts that might help suraj singh. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.