acd1.htm

来自「FM MUDULATION SYSTEM COMUNICATION」· HTM 代码 · 共 259 行 · 第 1/3 页

HTM
259
字号
here. As with all the examples, I've left the power supply out. You can use a bench
power supply set to 5v or use a onboard +5 regulator. Remember a few de-coupling 
capacitors, especially if you have trouble with the circuit working properly.
</p>
<table>
<tbody><tr><td>
<font face="ARIAL">
The 2 line x 16 character LCD modules are available from a wide range of
manufacturers and should all be compatible with the HD44780. The one I used to test this circuit
was a Powertip PC-1602F and an old Philips LTN211F-10 which was extracted from
a Poker Machine! The diagram to the right, shows the pin numbers for these
devices. When viewed from the front, the left pin is pin 14 and the right
pin is pin 1.
</font>
</td><td>
<center><img src="ACD1_files/lcdlayou.gif" alt="Pin Diagram of LCD Module" border="1"></center>
</td></tr>
</tbody></table>
</ul>

<font size="+1" face="ARIAL">Programming - Source Code</font>
<br><hr>
<ul>
<pre>/*  LCD Module Software                                               */
/*  17th May 1997			                              */
/*  Copyright 1997 Craig Peacock                                      */
/*  WWW     - http://www.senet.com.au/~cpeacock                       */
/*  Email   - cpeacock@senet.com.au                                   */
/*                                                                    */
/*  Register Select must be connected to Select Printer (PIN 17)      */
/*  Enable must be connected to Strobe (PIN1)                         */
/*  DATA 0:7 Connected to DATA 0:7                                    */

#include &lt;dos.h&gt;
#include &lt;string.h&gt;

#define PORTADDRESS 0x378  /* Enter Your Port Address Here */

#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2

void main(void)
{
 char string[] = {"Testing 1,2,3                           "
		  "It' Works !                             "};
 char init[10];
 int count;
 int len;
 init[0] = 0x0F; /* Init Display */
 init[1] = 0x01; /* Clear Display */
 init[2] = 0x38; /* Dual Line / 8 Bits */

 outportb(CONTROL, inportb(CONTROL) &amp; 0xDF); /* Reset Control Port - Make sure Forward Direction */

 outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */

 for (count = 0; count &lt;= 2; count++)
  {
   outportb(DATA, init[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
   outportb(CONTROL,inportb(CONTROL) &amp; 0xFE); /* Reset Strobe (Enable)*/
   delay(20);                                 /* Larger Delay for INIT */
  }

 outportb(CONTROL, inportb(CONTROL) &amp; 0xF7);  /* Reset Select Printer (Register Select) */

 len = strlen(string);

 for (count = 0; count &lt; len; count++)
  {
   outportb(DATA, string[count]);
   outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
   delay(2);
   outportb(CONTROL,inportb(CONTROL) &amp; 0xFE); /* Reset Strobe */
   delay(2);
  }
}
</pre>
<font face="ARIAL">
</font><p>
<font face="ARIAL">Above is the source code to get this example running. It's been written for Borland C, so 
if you are using a Microsoft compiler, then you will have to change the <i>outportb()</i>
function to <i>outp()</i> and <i>inportb()</i> to <i>inp()</i>. 
</font></p>
<p>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?