Docsity

LCD Interfacing-Interfacing Microprocessor-Codes, Study Guides, Projects, Research of Microprocessor and Interfacing

Toggle sidebar
bg1
// ***********************************************************
// Project: LCD Interfacing
// Author: Group # 9
// Module description: Implementing LCD interfacing using HD44780 type
// ***********************************************************
# define F_CPU 16000000UL
#include <avr\io.h> // Most basic include files
#include <avr\signal.h> // here
#include <util\delay.h>
#include <string.h>
# define DELAY 5
// ***********************************************************
// Function Prototypes
//
void op_char (char);
void initiallize (void);
void write (char);
// ***********************************************************
// Main program
//
int main(void)
{
DDRA = 0xFF; // To enable output on pins of PORTA
DDRD = 0x70; // To enable output on pins PD4 PD5 PD6
initiallize();
char text1[] = {"Bismillah"};
char text2[] = {"*Welcome*"};
op_char (0x0E); // To Turn on the display
while(1)
{
unsigned int i=0;
op_char (0x80); // To Position the cursor back on 1st line in each
loop
while(text1[i] !='\0')
{
write (text1[i]);
i++;
}
op_char(0xC0); // To move on to the next line
i = 0;
while(text2[i] !='\0')
{
write (text2[i]);
docsity.com
pf3

Partial preview of the text

Download LCD Interfacing-Interfacing Microprocessor-Codes and more Study Guides, Projects, Research Microprocessor and Interfacing in PDF only on Docsity!

// Project: LCD Interfacing // Author: Group # 9 // Module description: Implementing LCD interfacing using HD44780 type // ***********************************************************

define F_CPU 16000000UL

#include // Most basic include files #include // here #include #include

define DELAY 5

// *********************************************************** // Function Prototypes //

void op_char (char); void initiallize (void); void write (char);

// *********************************************************** // Main program // int main(void) { DDRA = 0xFF; // To enable output on pins of PORTA DDRD = 0x70; // To enable output on pins PD4 PD5 PD initiallize();

char text1[] = {"Bismillah"}; char text2[] = {"Welcome"};

op_char (0x0E); // To Turn on the display

while(1) { unsigned int i=0; op_char (0x80); // To Position the cursor back on 1st line in each loop

while(text1[i] !='\0') { write (text1[i]); i++; }

op_char(0xC0); // To move on to the next line

i = 0; while(text2[i] !='\0') { write (text2[i]);

i++; } } }

// Functions Definations //

// Initializing the LCD // =========================================================== void initiallize (void) { //STEP 1 _delay_ms(16); // to give delay of more than 15msec (roughly)

//STEP 2 op_char(0x30);

//STEP 3 op_char(0x30);

//STEP 4 op_char(0x30);

//STEP 5 // Part 1: op_char(0x3C); // To set interface length

// Part 2: op_char (0x08); // To turn off the display

// Part 3: op_char (0x01); // To clear the display

// Part 4: op_char (0x07); //Set cursor move direction

// Part 5: op_char (0x0E); //TO enable display or cursor }

// Operating Characteristics // =========================================================== void op_char (char value) { PORTD = 0x40; // only E is high PORTA = value; PORTD = 0x00; // E is low _delay_ms(DELAY); }