Professional Documents
Culture Documents
#define PIC18F4550
#include<string.h>
/* Function Prototypes */
void lcdinit(void); //Initialise LCD module
void line2(void); //Move to start of line 2
void home(void); //Move display cursor to home position
void clear(void); //Clear LCD display
void command(unsigned char lcd_comm); //Send command to LCD
void display(unsigned char lcd_data); //Send character to display
void display_string(char *lcd_message); // Send text string to display
/* Variables */
int x; // Every program should have one
char *lcd_message; // Pointer to the address of the String to send
to LCD
void setup()
{
/* Basic housekeeping. I/O pin configuration */
PORTE=0x00;
ADCON1=0x0F; // All pins are digital I/O
CMCON=0x07; // Comparators off. PORTA for digital I/O
TRISE=0x00; // All PORTE pins are outputs
PORTB=0x00;
TRISB=0x00; // All PORTB pins are outputs
}
command(0x01); // Clear/Home
delay(2); // Delay more than 1.53ms
/* Clear display */
void clear(void)
{
command(0x01);
}