lunes, 9 de enero de 2017

Configuración LCD 16x2 PIC 18F4550 mikroC PRO


 // LCD module connections
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;

sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
// End LCD module connections

char txt1[] = "mikroElektronika";
char txt2[] = "EasyPIC6";
char txt3[] = "Lcd4bit";
char txt4[] = "example";

char i;                              // Loop variable

void main() {

Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

  Lcd_Out(1,6,"WELCOME");                 // Write text in first row
  Lcd_Out(2,4,"HELLO WORLD");                 // Write text in second row
  Delay_ms(2000);

  Lcd_Cmd(_LCD_CLEAR);

    Lcd_Out(1,4,"ELECTRONIC");                 // Write text in first row
    Lcd_Out(2,5,"");                 // Write text in second row

  Delay_ms(2000);
    Lcd_Chr_Cp('O');
  delay_ms(200);
  Lcd_Chr_Cp('F');
  delay_ms(200);
  Lcd_Chr_Cp(' ');
  delay_ms(200);
  Lcd_Chr_Cp('N');
  delay_ms(200);
  Lcd_Chr_Cp('Z');
  delay_ms(200);
  Lcd_Chr_Cp('V');
  delay_ms(200);
  delay_ms(2000);

  lcd_cmd(_lcd_clear);


while(1){
int k;
  for(k=0; k<=16; k++){

   Lcd_Out(1,k,"ZEVALLOS");
   delay_ms(200);
   lcd_cmd(_lcd_clear);

  }

  for(k=15; k>=0; k--){

   Lcd_Out(1,k,"VEGA");
   delay_ms(200);
   lcd_cmd(_lcd_clear);

  }

}
}

No hay comentarios:

Publicar un comentario