PICELECTRONICA
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

Manejo de LCD 20x4

Ir abajo

Manejo de LCD 20x4 Empty Manejo de LCD 20x4

Mensaje  Somacruz Miér Mayo 09, 2012 10:51 pm

En dias pasados el usuario Kook me comento el problema de poder manejar un LCD de 20x4, le comente que no contaba con dicha LCD y que mucho menos habia llegado a utilizar una, sin embargo desperto mi curiosidad por su funcionamiento asi que me puse a rebuscar por la red acerca de algun recurso sobre este artilugio, cuando ya me estaba dando por vencido Crying or Very sad encontre un link hacia un foro de CCS (en ingles obviamente) pero donde el tipo compartia una libreria y un ejemplo para su chekeo, si bien no incluia una simulacion me puse a armarlo para verificar su funcionamiento

Captura de la simulacion

Manejo de LCD 20x4 I8dk3vIU4CsaJ

Codigo del ejemplo

Código:

#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include "flex_LCD4X20.c"   

//===================================
void main()
{
int8 i;
int8 b1, b2, b3, b4;

// The lcd_init() function should always be called once,
// near the start of your program.
lcd_init();

// Clear the LCD.
printf(lcd_putc, "\f");
delay_ms(500);


while(1)
  {
  // Test the clear screen and newline commands.
  // Also test that we can write to all 4 lines.
  printf(lcd_putc, "\fThis is the 1st line");
  printf(lcd_putc, "\nNext is the 2nd line");
  printf(lcd_putc, "\nThis is the 3rd line");
  printf(lcd_putc, "\nFinally the 4th line");
  delay_ms(3000);

  // Test some additional characters.
  printf(lcd_putc, "\fABCDEFGHIJKLMNOPQRST");
  printf(lcd_putc, "\nabcdefghijklmnopqrst");
  printf(lcd_putc, "\n12345678901234567890");
  printf(lcd_putc, "\n!@#$^&*(){}[]:;<>?/=");
  delay_ms(3000);

  // Clear the LCD.
  printf(lcd_putc, "\f");
  delay_ms(500);

  // Test that lcd_gotoxy() works.  Go to each of
  // the four corners and put a number in each one,
  // in a clockwise direction, starting with the upper
  // left corner.
  lcd_gotoxy(4, 2);       
  printf(lcd_putc, "Put a number in");   
  lcd_gotoxy(4, 3);       
  printf(lcd_putc, "each corner.");   
  lcd_gotoxy(1, 1);       
  printf(lcd_putc, "1");   
  lcd_gotoxy(20, 1);       
  printf(lcd_putc, "2");   
  lcd_gotoxy(20, 4);       
  printf(lcd_putc, "3");   
  lcd_gotoxy(1, 4);       
  printf(lcd_putc, "4");   
  delay_ms(3000);

// Read the character that was written in each corner
// of the LCD and display it.  This tests the lcd_getc()
// function.   
// The following test can only be done if we can read
// from the LCD.  If the RW pin is not used, then the
// LCD is in write-only mode, and we can't do this test.
// The #ifdef statement will prevent the code from
// being compiled, in that case.

#ifdef USE_RW_PIN   
  // Test if lcd_getc() can read
  // a byte from each corner.
  b1 = lcd_getc(1,1);   
  b2 = lcd_getc(20,1);   
  b3 = lcd_getc(20,4);   
  b4 = lcd_getc(1,4);   
  lcd_gotoxy(1, 1);       
  printf(lcd_putc, "\fRead these bytes\n");
  printf(lcd_putc, "from the 4 corners:\n\n");
  printf(lcd_putc, "    %c %c %c %c", b1, b2, b3, b4);       
  delay_ms(3000);
#endif

  // Type some characters and backspace over them.
  printf(lcd_putc, "\fType characters and\n");
  printf(lcd_putc,  "backspace over them.");
  delay_ms(2000);

  // Go to end of 2nd line.
  lcd_gotoxy(20, 2);       

  // Backspace over 2nd line.
  for(i = 0; i < 20; i++)
      {
      printf(lcd_putc," \b\b");
      delay_ms(150);
      }

  // Go to end of first line.               
  lcd_gotoxy(20, 1);       

  // Backspace over first line.
  for(i = 0; i < 20; i++)
      {
      printf(lcd_putc," \b\b");
      delay_ms(150);
      }         

  }   

}

Nota : Recalco nuevamente que ni el ejemplo ni la libreria son de mi autoria Shocked , fueron descargados del foro de CCS yo solo realize la simulacion para verificar su funcionamiento, dejo el link de descarga con la libreria y la simulacion espero q sean de su agrado, si alguien tiene la LCD ojala y ponga un videito para checar su funcionamiento, comenten, saludos

DESCARGA
Somacruz
Somacruz
Administrador
Administrador

Mensajes : 23
Fecha de inscripción : 20/04/2012
Edad : 41

http://solopic.wordpress.com

Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.