<?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_Digital_Outputs_%28Ports%29</id>
	<title>C Example: Digital Outputs (Ports) - 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_Digital_Outputs_%28Ports%29"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=C_Example:_Digital_Outputs_(Ports)&amp;action=history"/>
	<updated>2026-05-17T13:32:19Z</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:_Digital_Outputs_(Ports)&amp;diff=4965&amp;oldid=prev</id>
		<title>LIMS at 20:43, 25 June 2007</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=C_Example:_Digital_Outputs_(Ports)&amp;diff=4965&amp;oldid=prev"/>
		<updated>2007-06-25T20:43:45Z</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;__TOC__&lt;br /&gt;
==Code==&lt;br /&gt;
Program to count in binary from 0-15 and display on LEDs.&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;
Define variables to be used in main program.  Both are defined as&lt;br /&gt;
8-bit numbers, with count already being assigned a value while temp&lt;br /&gt;
is left unassigned.&lt;br /&gt;
&lt;br /&gt;
   int count = 0;&lt;br /&gt;
   int temp;&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;
Set Port D to be an output (0).  The SET_TRIS_X function can also be&lt;br /&gt;
used to set ports to be inputs (1).&lt;br /&gt;
&lt;br /&gt;
      SET_TRIS_D(0);&lt;br /&gt;
&lt;br /&gt;
Use while to create an infinite loop.&lt;br /&gt;
&lt;br /&gt;
      while(TRUE){&lt;br /&gt;
&lt;br /&gt;
Assign the value of &amp;quot;count&amp;quot; to Port D, thus displaying it on&lt;br /&gt;
the LEDs connected to Port D.&lt;br /&gt;
&lt;br /&gt;
         OUTPUT_D(count);&lt;br /&gt;
         delay_ms(500);&lt;br /&gt;
&lt;br /&gt;
Check the value of &amp;quot;count&amp;quot;, and either increment it or reset it&lt;br /&gt;
to zero.&lt;br /&gt;
      &lt;br /&gt;
         if(count&amp;lt;15){&lt;br /&gt;
            temp = count;&lt;br /&gt;
            count = temp + 1;}&lt;br /&gt;
         else {&lt;br /&gt;
            count = 0;}&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
==Associated Circuitry==&lt;/div&gt;</summary>
		<author><name>LIMS</name></author>
	</entry>
</feed>