Control2 Lcds
Control2 Lcds
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)
SPI_Lcd8_Config(0);
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);
}
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;
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;
}
}
}