PIC16F877A LCD Interface

By Kunal Kapoor
12-05-2018
488

RF control robot, we will be controlling a 4 motor robot using a wireless communication.

Check the reference at section below for further information on RF Module.

 

In this project we will be using a RF module to transmit a signal to robot. The robot will be having a receiver module which will receive the signal and decode it to operate the directions of the robot.

The RF module used in this project is a short range 50m range module, 433MHz frequency.

 


Project


Circuit Diagram:

IDE used : MPLAB by Microchip


Code:


main.h:

#include 
#include "delay.h"


//DEFINE MACROS
__CONFIG (0x2F0A);


//FUNCTION PROTOTYPES
void main(void);


delay.h:

#ifndef DELAY_H
#define DELAY_H

//FUNCTION PROTOTYPE
void delay(unsigned int time);

//DEFINE USER DEFINED DATATYPE
typedef unsigned char ubyte;

#endif


delay.c:

#include "delay.h"

void Delay(unsigned int time)
{
	unsigned char pause;
	while( time > 0)
	{
		pause = 255;
		while(pause--);
		time--;
	}
}

main.c:

#include"main.h"

unsigned int i=0;
void lcd_command(unsigned char );
void lcd_data(unsigned char y[] );
void lcd_init();
 
void main()
{
TRISD=0x00;
TRISE=0x00;
lcd_init();
lcd_command(0x80);
lcd_data("c");
}

void lcd_command(unsigned char x)
{
PORTE&=0xfc;  //R/S=0,R/W=0
PORTD=x;
PORTE |=0x04;
delay(1);
PORTE &=0xfb;
delay(1);
}

void lcd_data(unsigned char y[])
{
PORTE|=0x01;  //R/S=1
PORTE&=0xfd;  //R/W=0
PORTD=y;
PORTE |=0x04;
delay(1);
PORTE &=0xfb;
delay(1);
}

void lcd_init()
{
lcd_command(0x38);
lcd_command(0x14);
lcd_command(0x0c);
lcd_command(0x06);
lcd_command(0x01);
lcd_command(0x02);
}
Output Screen:


Download the code from here



Related Tutorials