0% found this document useful (0 votes)
77 views8 pages

Control2 Lcds

The document describes a program for controlling two LCDs with a PIC microcontroller. It discusses using an 8-bit LCD library and manually forming characters on LCD 2 to display messages. The program is simulated in Proteus for both implementations.

Uploaded by

Lenin Cadena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views8 pages

Control2 Lcds

The document describes a program for controlling two LCDs with a PIC microcontroller. It discusses using an 8-bit LCD library and manually forming characters on LCD 2 to display messages. The program is simulated in Proteus for both implementations.

Uploaded by

Lenin Cadena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

UNIVERSIDAD POLIETECNICA SALESIANA

SISTEMAS MICROPROCESADOS
NOMBRE: Cadena Lenin Cadena
CURSO: 6to G-3
1.- Realizar un programa en MikroC para controlar 2 LCDs con un microcontrolador 16F877A , el
cual debe mostrar un mensaje en cada Lcd.
a).-Mediante la LCD Library 8 bits
void f1(char pos_row, char pos_char);
void f2(char pos_row, char pos_char);
// Port Expander module connections

(8 bits)

sbit SPExpanderRST at RC0_bit;


sbit SPExpanderCS at RC1_bit;
sbit SPExpanderRST_Direction at TRISC0_bit;
sbit SPExpanderCS_Direction at TRISC1_bit;
// End Port Expander module connections
//Pines de configuracion lcd 1
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
const char chip[] = {6,15,6,18,31,19,6,27};
const char chip2[] = {6,15,6,6,15,15,6,15};
char txt[] = "MANEJO DE 2 LCDS";
char txt1[] = "DEBER MICROS I";

char txt2[] = "Lenin Cadena";


short int i,j;
void main() {
TRISB=0;
TRISD=0xff;
PORTB=0;
PORTD=0;
//inicializacion extecnion a 8 bits del lcd
SPI1_Init();

// Initialize SPI module used with PortExpander

SPI_Lcd8_Config(0);

// Initialize Lcd over SPI interface

SPI_Lcd8_Cmd(_LCD_CLEAR);

// Clear display

SPI_Lcd8_Cmd(_LCD_CURSOR_OFF);
//configuracion lcd de 4 bits
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR);
SPI_Lcd8_Cmd(_LCD_CLEAR);
while(1){
if (Button(&PORTD, 0, 1, 1)) {
SPI_Lcd8_Out(2,3, txt2);
for(i=16; i>-16; i--) {
SPI_Lcd8_Out(1,16,txt1);
SPI_Lcd8_Cmd(_LCD_SHIFT_LEFT);
delay_ms(100);
}
}
if (Button(&PORTD, 1, 1, 1)) {
for(i=16;i>=0;i--){
f2(1,i);
f1(1,i);
delay_ms(300);
Lcd_Cmd(_LCD_CLEAR);

// Turn cursor off

}
for(j=0; j<24; j++) {
Lcd_Out(2,1,txt);
Lcd_Cmd(_LCD_SHIFT_RIGHT);
delay_ms(100);
if(j==23){j=0;}
}
}
}
}
void f1(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(chip[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
void f2(char pos_row, char pos_char) {
char i;
Lcd_Cmd(64);
for (i = 0; i<=7; i++) Lcd_Chr_CP(chip2[i]);
Lcd_Cmd(_LCD_RETURN_HOME);
Lcd_Chr(pos_row, pos_char, 0);
}
b).-Mediante formarcion de caracteres en Lcd 2
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D4_Direction at TRISB0_bit;


sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
char txt1[] = "CONTROL DE 2 LCDS";
char txt2[] = "Cadena Lenin";
short int est0,est1;
const tiempo=50,x=1;
void main(){
TRISD=0xFF;
TRISC=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1){
if(Button(&PORTD,0,1,0))est0=0;
if(est0==0&&Button(&PORTD,0,1,1)){
Lcd_Out(1,1,txt1);
Lcd_Out(2,1,txt2);
est1=1;
}
if(Button(&PORTD,1,1,0))est1=0;
if(est1==0&&Button(&PORTD,1,1,1)){
portc=0b00000011;
portc=0b00100011;
portc=0b00000010;
portc=0b00100010;
portc=0b00000010;
portc=0b00100010;
portc=0b00000001;
portc=0b00100001;
portc=0b00000000;
portc=0b00100000;

delay_ms(x);
portc=0b00001111;
delay_ms(x);
portc=0b00101111;
delay_ms(x);
portc=0b00010000;
delay_ms(x);
portc=0b00010100;
portc=0b00110100;
portc=0b00011010;
portc=0b00111010;
//////M
portc=0b00010100;
delay_ms(tiempo);
portc=0b00110100;
delay_ms(tiempo);
portc=0b00011101;
delay_ms(tiempo);
portc=0b00111101;
delay_ms(tiempo);
///////I
portc=0b00010100;
delay_ms(tiempo);
portc=0b00110100;
delay_ms(tiempo);
portc=0b00011001;
delay_ms(tiempo);
portc=0b00111001;
delay_ms(tiempo);
///////C
portc=0b00010100;
delay_ms(tiempo);
portc=0b00110100;

delay_ms(tiempo);
portc=0b00010011;
delay_ms(tiempo);
portc=0b00110011;
delay_ms(tiempo);
//////R
portc=0b00010101;
delay_ms(tiempo);
portc=0b00110101;
delay_ms(tiempo);
portc=0b00010010;
delay_ms(tiempo);
portc=0b00110010;
delay_ms(tiempo);
//////O
portc=0b00010100;
delay_ms(tiempo);
portc=0b00110100;
delay_ms(tiempo);
portc=0b00011111;
delay_ms(tiempo);
portc=0b00111111;
delay_ms(tiempo);
/////S
portc=0b00010101;
delay_ms(tiempo);
portc=0b00110101;
delay_ms(tiempo);
portc=0b00010011;
delay_ms(tiempo);
portc=0b00110011;
delay_ms(tiempo);
/////1

portc=0b00010011;
delay_ms(tiempo);
portc=0b00110011;
delay_ms(tiempo);
portc=0b00010001;
delay_ms(tiempo);
portc=0b00110001;
delay_ms(tiempo);
est1=1;
}
}
}

1.- SIMULACION EN PROTEUS DEL CIRCUITO CON LA LIBRERA DE 8 BITS

2.- SIMULACION EN PROTEUS DEL CIRCUITO FORMARNDO LA FRASE

You might also like