Drive a 2x16 or 4x20 Hitachi LCD with a single pin via a 74HC595 Shift Register

Started by top204, Feb 06, 2021, 03:58 PM

Previous topic - Next topic

Pepe


Abdullah

Abdullah

Pepe

Cortando la parte del código que está  en el programa principal y pegándola en un nuevo archivo con extensión .inc

Pepe


Stephen Moss

Quote from: Abdullah on Today at 04:07 AM
Quote from: Pepe on Nov 06, 2025, 08:42 PMdemo works
Sir how to create INCLUDE file
I don't think it works well as an include because there is no way (that I have found) of passing the Port & Pin numbers used to control the LCD.
Therefore, if you use the include in several projects (which is the whole point of it), you have three choices...
  • Use the same LCD pins to control or every project. However that may not be practical as the next device you use may not have that port on it, or you need to use those pins for one of the hardware modules.
  • Edit the LCD control pin in the include file when the default pins cannot be used for reasons outline in item 1. The problem then is that when you go back to a program that used different pins and re-compile the LCD will no longer get any data as the pins used for the LCD has changed.
  • You can remove the LCD pin assignments from the include file and remember to place them in you main file every time you write program that requires an LCD display, only keeping the LCD subroutines in the include file that handle things such a print and clear screen.

Abdullah

Quote from: Stephen Moss on Today at 02:35 PM
Quote from: Abdullah on Today at 04:07 AM
Quote from: Pepe on Nov 06, 2025, 08:42 PMdemo works
Sir how to create INCLUDE file
I don't think it works well as an include because there is no way (that I have found) of passing the Port & Pin numbers used to control the LCD.
Therefore, if you use the include in several projects (which is the whole point of it), you have three choices...
  • Use the same LCD pins to control or every project. However that may not be practical as the next device you use may not have that port on it, or you need to use those pins for one of the hardware modules.
  • Edit the LCD control pin in the include file when the default pins cannot be used for reasons outline in item 1. The problem then is that when you go back to a program that used different pins and re-compile the LCD will no longer get any data as the pins used for the LCD has changed.
  • You can remove the LCD pin assignments from the include file and remember to place them in you main file every time you write program that requires an LCD display, only keeping the LCD subroutines in the include file that handle things such a print and clear screen.

Yes sir, I wanted to shorten the code. My work is done now. Actually, the LCD code needs to be written repeatedly, so I created an include file for it to avoid changing the code again and again.
Abdullah

Pepe

demo fixed