Posts

Showing posts with the label ATMEGA 32

LCD interfacing using AVR(ATMEGA 32)

Image
SIMULATOR: PROTEUS 8.0 SOFTWARE: KEIL 4.0 CIRCUIT DIAGRAM: PIN DESCRIPTION OF LCD: PROGRAM: #include<avr/io.h>   // header file for AVR #include<util/delay.h> // header file for delay function void lcd_init(void); void lcd_command(char c); void lcd_data(char d); void str(char a[]); int main(void)    // main program   { DDRB=0XFF;  //  Select PORT B as an output port DDRD=0XFF; // Select PORT D as an output port lcd_init();      // initialize the lcd while(1)             // continuous loop   { str("WELCOME TO THE");  lcd_command(0xc0);                  // move cursor to the next line str("EMBEDDED SYSTEM"); lcd_command(0x01);           // clear display } } void lcd_init(void)  // lcd initialization function { lcd_command(0x38); //8bit,2 line,5*7 matrix lcd_command(0x0c); //cursor off,display on lcd_command(0x80);//force cursor to the beginning of the first line lcd_command(0x01);// clear display lcd_co

Blinking LEDs using AVR (ATMEGA 32)

Image
SIMULATOR:   PROTEUS 8.0 SOFTWARE: WIN AVR CIRCUIT DIAGRAM: CIRCUIT DESCRIPTION: Here, LEDs are connected to the port b register of AVR. I have used the current-sinking arrangement. Therefore, I have provided logic 0 to turn on the LED and logic 1 to turn off the LED. PROGRAM: #include<avr/io.h>     void delay(unsigned int t); // delay function int main(void)     // main program { DDRB=0XFF;   //   Select PORT B as an output port while(1)              // continuous loop { PORTB=0X00;   // turned on the LEDs delay(10); // delay  PORTB=0XFF; // turned off the LEDs } } void delay(unsigned int t) // delay function { unsigned int i; for(i=0;i<1275*t;i++); } PROGRAM DESCRIPTION: DDRx: Here, DDR stands for data direction register and x represents the port number. Here, I have used port b. So, in place of x,I have written B. It is used to decide whether the port is acting as an input port or an output port. DDRx=0X00; // port x is acting as