<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=C_Example%3A_Serial_LCD</id>
	<title>C Example: Serial LCD - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=C_Example%3A_Serial_LCD"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=C_Example:_Serial_LCD&amp;action=history"/>
	<updated>2026-05-26T14:23:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=C_Example:_Serial_LCD&amp;diff=5436&amp;oldid=prev</id>
		<title>LIMS at 20:06, 10 November 2007</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=C_Example:_Serial_LCD&amp;diff=5436&amp;oldid=prev"/>
		<updated>2007-11-10T20:06:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:06, 10 November 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay_ms(5);&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay_ms(5);&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      printf(&quot;Something&quot;);&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      printf(&quot;Something&quot;);&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      i_count++;&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay_ms(500);&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay_ms(500);&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      }&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      }&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>LIMS</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=C_Example:_Serial_LCD&amp;diff=5435&amp;oldid=prev</id>
		<title>LIMS at 20:06, 10 November 2007</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=C_Example:_Serial_LCD&amp;diff=5435&amp;oldid=prev"/>
		<updated>2007-11-10T20:06:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Serial LCD with the PIC==&lt;br /&gt;
An example serial LCD can be found at:&lt;br /&gt;
[http://www.parallax.com/Store/Accessories/Displays/tabid/159/CategoryID/34/List/0/Level/a/ProductID/50/Default.aspx?SortField=ProductName%2cProductName]&lt;br /&gt;
This is a 2x16 backlit LCD that displays ASCII characters at 2400, 9600, and 19200 baud.&lt;br /&gt;
It requires a 5V connection, a ground connection, and only 1 i/o line for communication.&lt;br /&gt;
The manual for this LCD can be found at:&lt;br /&gt;
[http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/SerialLCD-v2.0.pdf]&lt;br /&gt;
This LCD requires TTL level RS-232 communication, which matches the output of the PIC, so a level shifting chip is not required.&lt;br /&gt;
Connect your PIC output pin directly to the LCD rx pin.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
Program to display output using a serial LCD&lt;br /&gt;
&lt;br /&gt;
First include header file with definitions for specific PIC. &lt;br /&gt;
Set fuses.  HS is type of external clock, low voltage protection &lt;br /&gt;
(LVP) is off, and the watchdog timer (WDT) is off. &lt;br /&gt;
External clock frequency of 20 MHz is specified. &lt;br /&gt;
&lt;br /&gt;
   #include &amp;lt;18f4520.h&amp;gt;&lt;br /&gt;
   #fuses HS,NOLVP,NOWDT&lt;br /&gt;
   #use delay (clock=20000000)&lt;br /&gt;
&lt;br /&gt;
Setup the PIC to use pin A0 (or any other pin) for RS-232.&lt;br /&gt;
Match the baud rate to your LCD.  &lt;br /&gt;
&lt;br /&gt;
   #use rs232(baud=19200, xmit=PIN_A0)&lt;br /&gt;
&lt;br /&gt;
Begin main body of program.&lt;br /&gt;
&lt;br /&gt;
   void main(void) {&lt;br /&gt;
&lt;br /&gt;
Turn on the LCD by placing the communication pin high for 100mS&lt;br /&gt;
&lt;br /&gt;
   output_high(PIN_A0);&lt;br /&gt;
   delay_ms(100);&lt;br /&gt;
&lt;br /&gt;
Send the LCD a character to initialize the screen.&lt;br /&gt;
A list of characters (0-255) and what they do appears in the manual.&lt;br /&gt;
It is a good idea to add a slight delay after outputting to the LCD to avoid the LCD missing signals.&lt;br /&gt;
&lt;br /&gt;
   putc(25); //turn lcd on, cursor on and character blink&lt;br /&gt;
   delay_ms(1);&lt;br /&gt;
   putc(17); //backlight on&lt;br /&gt;
   delay_ms(1);&lt;br /&gt;
&lt;br /&gt;
Note that the command for clearing the LCD and setting the cursor to the origin takes the LCD several steps and needs a longer pause.&lt;br /&gt;
&lt;br /&gt;
   putc(12); //return to origin and clear, must wait 5ms&lt;br /&gt;
   delay_ms(5);&lt;br /&gt;
&lt;br /&gt;
Output some text to the LCD, show it for a second.&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;LCD Test Program&amp;quot;);&lt;br /&gt;
   delay_ms(1000);&lt;br /&gt;
&lt;br /&gt;
Use while to set up infinite loop.&lt;br /&gt;
&lt;br /&gt;
      while(TRUE){&lt;br /&gt;
&lt;br /&gt;
Clear the LCD screen and write something.&lt;br /&gt;
Lookup the printf() function for instructions on how to send variables.&lt;br /&gt;
Example: printf(&amp;quot;temp = %f deg C&amp;quot;, temperature); will place the truncated float temperature in place of the %f&lt;br /&gt;
&lt;br /&gt;
      putc(12); //return to origin and clear, must wait 5ms&lt;br /&gt;
      delay_ms(5);&lt;br /&gt;
      printf(&amp;quot;Something&amp;quot;);&lt;br /&gt;
      i_count++;&lt;br /&gt;
      delay_ms(500);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Associated Circuitry==&lt;/div&gt;</summary>
		<author><name>LIMS</name></author>
	</entry>
</feed>