create account

Driving an LCD with PIC16F877A EN/ES by electronico

View this thread on: hive.blogpeakd.comecency.com
· @electronico ·
$9.29
Driving an LCD with PIC16F877A EN/ES
 <div class=text-justify> 

After having seen some theory about LCDs it is time to go into details about how to print text on LCDs using a microcontroller. For this we will use C language in the programming and we will simulate with proteus.

> Luego de haber visto un poco de teoría sobre LCDs ha llegado el momento de entrar en detalles sobre cómo imprimir un texto en este tipo de pantallas usando un micro controlador. Para ello usaremos lenguaje C en la programación y simularemos con proteus.

 <center> ![](https://images.ecency.com/DQmQaeHsz7ZTKeNXoGTmwEgtqM7Ze1KXoJ6o2PpCquJHNDA/image.png) </center>

<center>
<table>
<thead>
<tr><th><center><div class="phishy">Instructions</div></center></th></tr>
</thead>
<tbody>
</tbody>
</table>
</center>

In C language LCD handling does not require many lines, however for the case of our compiler we will add a library that will facilitate the task even more. You must define the connection pins between the microcontroller and the LCD, the LCD pins have fixed names, what is chosen is which pins of the microcontroller will connect each pin of the LCD which we do as follows:

> En lenguaje C el manejo de LCD no requiere de muchas líneas, sin embargo para el caso de nuestro compilador añadiremos una librería que facilitará aún más la tarea. Se deben definir los pines de conexión entre el microcontrolador y la LCD, los pines de la LCD tienen nombres fijos, lo que se elige es a qué pines del microcontrolador se conectará cada pin de la LCD lo cual hacemos de la siguiente forma:

~~~
#define LCD_DB4   PIN_D4   

#define LCD_DB5   PIN_D5

#define LCD_DB6   PIN_D6

#define LCD_DB7   PIN_D7

#define LCD_RS    PIN_D2

#define LCD_E     PIN_D3   
~~~

The following instructions are used to handle the operation:
* lcd_init(); allows to initialize the LCD.
* lcd_gotoxy(x,y); places the pointer at the indicated position inside the parenthesis before starting the writing process.
* lcd_putc("text"); prints a text on the screen starting from the pointer position, remember the LCD limitations, i.e. do not print a text so large that it does not fit on the screen.
* lcd_clear(); Clears the screen, this action is necessary to write something new.

 <blockquote> 

Para manejar la operación se usan las siguientes instrucciones:
* lcd_init(); permite inicializar la LCD.
* lcd_gotoxy(x,y);  ubica el puntero en la posición indicada dentro del parentesis antes de iniciar la escritura.
* lcd_putc("text"); Imprime un texto en pantalla partiendo desde la posición del puntero, se debe recordar las limitaciones del LCD, es decir, no imprimir un texto tan grande que no entre en pantalla.
* lcd_clear(); Limpia la pantalla, esta acción es necesaria para escribir algo nuevo.
</blockquote> 

I have taken advantage of the explanation of the Matrix Display to shape a dynamic signature in my articles so now I will use the LCD as a complement, let's see how to print the text "Thanks for Reading" Vote, Comment, Reblog, follow me, @electronico. In the top row it will appear in English and in the bottom row in Spanish.

He aprovechado la explicación del Display matricial para dar forma a una firma dinámica en mis artículos así que ahora usaré el LCD como complemento, vamos a ver como imprimir el texto "Gracias por Leer" Vota, Comenta, Rebloguea, sigueme, @electronico. En la fila de arriba aparecerá en inglés y en la de abajo en español.

<center>
<table>
<thead>
<tr><th><center><div class="phishy">Programming</div></center></th></tr>
</thead>
<tbody>
</tbody>
</table>
</center>

We start by writing our header as usual in which we define our microcontroller, fuses, clock frequency and input/output handling function.

> Iniciamos escribiendo nuestro encabezado como de costumbre en el cual definimos nuestro microcontrolador, fusibles, frecuencia del reloj y función para manejo de entradas/salidas.

~~~
#include <16f877a.h>

#fuses HS,NOWDT,NOPROTECT,NOPUT,NOLVP,BROWNOUT 

#use delay(clock=20M)

#use standard_io(D)
~~~

Now we define on which pins of the microcontroller the LCD pins will be connected and in the last line we add the LCD library.

> Ahora definimos en qué pines del microcontrolador se conectarán los pines de la LCD y en la última línea agregamos la librería de la LCD.

~~~
#define LCD_DB4   PIN_D4       

#define LCD_DB5   PIN_D5

#define LCD_DB6   PIN_D6

#define LCD_DB7   PIN_D7

#define LCD_RS    PIN_D2

#define LCD_E     PIN_D3

#include <LCD_16X2.c       
~~~

Next we will initialize our LCD in the main program with the instruction already described and then create an infinitely repeating while loop in which we will write the instructions that will allow us to display the text.
We place the pointer in (1,1) to write in the top row and in (1,2) to write in the bottom row, then we set a delay (delay_ms) that determines how long we want to display that text, finally we clear the screen and print the next text doing this until we print all of them.

> Lo siguiente será inicializar nuestra LCD en el programa principal con la instrucción ya descrita y luego crear un bucle while de repetición infinita en el cual escribiremos las instrucciónes que nos permitirán mostrar el texto.
Ubicamos el puntero en (1,1) para escribir en la fila de arriba y en (1,2) para escribir en la fila de abajo, luego se establece un retardo (delay_ms) que determina durante cuanto tiempo queremos mostrar ese texto, finalmente se limpia la pantalla y se imprime el siguiente texto haciendo esto hasta imprimir todos.

~~~
void main()
{

  lcd_init();                    
  
  while(true)

  {

    lcd_gotoxy(1,1);             

    lcd_putc("Thank you");

    lcd_gotoxy(1,2);             

    lcd_putc("For read");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_gotoxy(1,1);             

    lcd_putc("Gracias");

    lcd_gotoxy(1,2);             

    lcd_putc("Por leer");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_putc("Upvote");

    lcd_gotoxy(1,2);             

    lcd_putc("Vote");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_putc("Comment");

    lcd_gotoxy(1,2);             

    lcd_putc("comente");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_putc("Reblog");

    lcd_gotoxy(1,2);             

    lcd_putc("Rebloguee");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_putc("Follow");

    lcd_gotoxy(1,2);             

    lcd_putc("Siga");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

    lcd_putc("////////////////");

    lcd_gotoxy(1,2);             

    lcd_putc("//@electronico//");

    delay_ms(700);    

    lcd_clear();

    delay_ms(200);

  }
}
~~~

With all the code already defined, it only remains to compile and test in our proteus simulator.

> Con todo el código ya definido solo queda compilar y probar en nuestro simulador proteus.

 <center> ![](https://images.ecency.com/DQmdiY9RgDrLduVqTSw134iEMyqnoE2q6bsoMzcGjEbnTVa/lcd.gif) </center>

<center>![](https://images.ecency.com/DQmWaaRYnUU8YbvG53M2CDBq1Z8NTaDMqffgDqQPQdbktRP/image.png) ![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)![](https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif)</center>
</div>


👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 387 others
👎  ,
properties (23)
authorelectronico
permlinkdriving-an-lcd-with-pic16f877a
categoryhive-196387
json_metadata{"image":["https://images.ecency.com/DQmQaeHsz7ZTKeNXoGTmwEgtqM7Ze1KXoJ6o2PpCquJHNDA/image.png","https://images.ecency.com/DQmdiY9RgDrLduVqTSw134iEMyqnoE2q6bsoMzcGjEbnTVa/lcd.gif","https://images.ecency.com/DQmWaaRYnUU8YbvG53M2CDBq1Z8NTaDMqffgDqQPQdbktRP/image.png","https://images.ecency.com/DQmWMb7UWTpsP83M7fvHB4NQ57whh5xBzvHcKKknCJRBUSU/20221228_185126.gif"],"users":["electronico","electronico"],"tags":["hive-196387","ocd","gems","chessbrothers","entropia","education","technology","proofofbrain","neoxian","electronica-ie"],"description":"","app":"ecency/3.0.30-vision","format":"markdown+html"}
created2023-01-02 18:28:21
last_update2023-01-02 18:28:21
depth0
children6
last_payout2023-01-09 18:28:21
cashout_time1969-12-31 23:59:59
total_payout_value4.673 HBD
curator_payout_value4.614 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,813
author_reputation43,746,257,869,160
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,562,389
net_rshares24,528,444,701,655
author_curate_reward""
vote details (453)
@chessbrotherspro ·
<h3>¡Enhorabuena!</h3><hr /><div class="pull-right"><img src="https://images.hive.blog/DQmQLssYuuJP2neoTVUbMRzvAu4Ptg7Vwt92aTM7Z3gNovg/cb-logo-150.png" alt="Has recibido el voto de PROYECTO CHESS BROTHERS"/></div><div class="text-justify"><h3>✅ Has hecho un buen trabajo, por lo cual tu publicación ha sido valorada y ha recibido el apoyo de parte de <a href="/@chessbrotherspro"><b>CHESS BROTHERS</b></a> ♔ 💪</h3><p><br>♟   Te invitamos a usar nuestra etiqueta <b>#chessbrothers</b> y a que aprendas más <a href="/@chessbrotherspro/presentando-al-proyecto-chess-brothers-la-comunidad-mas-innovadora-que-combina-el-ajedrez-el-acondicionamiento-fisico-y-mas"><b>sobre nosotros</b></a>.</p><p>♟♟ También puedes contactarnos en nuestro <a href="https://discord.gg/73sK9ZTGqJ" rel="noopener" title="Esto lleva al servidor en Discord de Chess Brothers"><b>servidor de Discord</b></a> y promocionar allí tus publicaciones.</p><p>♟♟♟ Considera <a href="/@chessbrotherspro/el-trabajo-en-equipo-vale-la-pena-unete-al-trail-de-curacion-de-chess-brothers-apoyando-la-labora-realizada-y-obteniendo"><b>unirte a nuestro trail de curación</b></a> para que trabajemos en equipo y recibas recompensas automáticamente.</p><p>♞♟  Echa un vistazo a nuestra cuenta <a href="/@chessbrotherspro"><b>@chessbrotherspro</b></a> para que te informes sobre el proceso de curación llevado a diario por nuestro equipo.</p><p><br>🏅 Si quieres obtener ganancias con tu delegacion de HP y apoyar a nuestro proyecto, te invitamos a unirte al plan <i>Master Investor</i>. <a href='/@chessbrotherspro/master-investor-plan-or-programa'>Aquí puedes aprender cómo hacerlo.</a></p></div><div class="text-center"><p><br>Cordialmente</p><p><strong><em>El equipo de CHESS BROTHERS</em></strong></p></div>
properties (22)
authorchessbrotherspro
permlinkre-driving-an-lcd-with-pic16f877a
categoryhive-196387
json_metadata""
created2023-01-03 13:32:06
last_update2023-01-03 13:32:06
depth1
children1
last_payout2023-01-10 13:32:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,762
author_reputation78,171,031,077,020
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,582,448
net_rshares0
@electronico ·
Gracias gente bella. Que Dios les multiplique!!
properties (22)
authorelectronico
permlinkre-chessbrotherspro-202313t93617229z
categoryhive-196387
json_metadata{"tags":["ecency"],"app":"ecency/3.0.30-vision","format":"markdown+html"}
created2023-01-03 13:38:00
last_update2023-01-03 13:38:00
depth2
children0
last_payout2023-01-10 13:38:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length47
author_reputation43,746,257,869,160
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,582,590
net_rshares0
@ecency ·
**Yay!** 🤗<br>Your content has been **boosted with Ecency Points**, by @electronico. <br>Use Ecency daily to boost your growth on platform! <br><br><b>Support Ecency</b><br>[Vote for new Proposal](https://hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B245%5D&approve=true)<br>[Delegate HP and earn more](https://ecency.com/hive-125125/@ecency/daily-100-curation-rewards)
properties (22)
authorecency
permlinkre-202312t204520839z
categoryhive-196387
json_metadata{"tags":["ecency"],"app":"ecency/3.0.20-welcome","format":"markdown+html"}
created2023-01-02 20:45:33
last_update2023-01-02 20:45:33
depth1
children0
last_payout2023-01-09 20:45:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length381
author_reputation624,418,221,988,018
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,565,322
net_rshares0
@hivebuzz ·
Dear @electronico,<br>We really appreciated your support for our previous proposal but it expired end of December.<br>May we ask you renew your support for the new proposal (#248) so that our team can continue their work?<br>You can support it on [Peakd](https://peakd.com/me/proposals/248), [Ecency](https://ecency.com/proposals/248), [Hive.blog](https://wallet.hive.blog/proposals) or [using HiveSigner](https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22248%22%5D&approve=true).<br>https://peakd.com/proposals/248<br>Thank you!
properties (22)
authorhivebuzz
permlinktxt-electronico-20230103t213132
categoryhive-196387
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2023-01-03 21:31:33
last_update2023-01-03 21:31:33
depth1
children0
last_payout2023-01-10 21:31:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length548
author_reputation369,420,202,188,940
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,592,868
net_rshares0
@stemsocial ·
re-electronico-driving-an-lcd-with-pic16f877a-20230103t214049440z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-electronico-driving-an-lcd-with-pic16f877a-20230103t214049440z
categoryhive-196387
json_metadata{"app":"STEMsocial"}
created2023-01-03 21:40:48
last_update2023-01-03 21:40:48
depth1
children1
last_payout2023-01-10 21:40:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,919,516,021,813
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,593,056
net_rshares0
@electronico ·
😍😍😍😍
properties (22)
authorelectronico
permlinkre-stemsocial-202314t75219219z
categoryhive-196387
json_metadata{"tags":["ecency"],"app":"ecency/3.0.30-vision","format":"markdown+html"}
created2023-01-04 11:54:06
last_update2023-01-04 11:54:06
depth2
children0
last_payout2023-01-11 11:54:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4
author_reputation43,746,257,869,160
root_title"Driving an LCD with PIC16F877A EN/ES"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id119,606,213
net_rshares0