<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2865116231154819529</id><updated>2012-01-20T10:15:22.790-08:00</updated><category term='SPI Tutorial'/><title type='text'>Microchip PIC Lessons</title><subtitle type='html'>Lessons and discussions on the Microchip PIC programming...  Primarily using development board from Futurlec and compilers from MikroElektronika</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4892396803005721414</id><published>2009-06-28T19:03:00.000-07:00</published><updated>2009-06-28T19:49:15.096-07:00</updated><title type='text'>USB Communication...</title><content type='html'>The USB interface is heaven for the users...  mostly plug and play...  or simply install the driver and everything would be working from there on...  After short journey into USB, I realized it was a far jump from the RS232 I'm used to.&lt;br /&gt;&lt;br /&gt;My learning points:&lt;br /&gt;&lt;br /&gt;1.  USB devices must have some intelligence built in.  When you connect a device to a serial port, windows does not do anything UNTIL you tell it do so.  Remember the old days when you connect a serial modem?  You have to tell windows you have connected a serial modem and then install the necessary driver and then you can start using it by telling windows the comm port, baud rate, etc.&lt;br /&gt;&lt;br /&gt;2. With USB, the moment you plug it that device, windows knows that a USB device has been connected.  It will automatically try to identify the device and 'configure' it for use.  If it fails to find a suitable &lt;span style="font-style: italic;"&gt;driver&lt;/span&gt; or if it fail to properly communicate with the device, then it will complain... asking you for the driver or simply state that the USB device fails to be recognized.&lt;br /&gt;&lt;br /&gt;3.  When windows detect a USB device connection (&lt;span style="font-style: italic;"&gt;pull up resistor on the data line&lt;/span&gt;)...  it will query the device for its' class (&lt;span style="font-style: italic;"&gt;mass storage, HID, etc&lt;/span&gt;).  If the driver for the class is already available to windows then it will just install the driver and the device is ready for use...&lt;br /&gt;&lt;br /&gt;4.  SO, if you want you PIC to talk to the PC via USB... several key things need to be understood and programmed for...&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;**  Your PIC must comply to the USB-bus strict timing requirement... for full speed USB, the timing is based on 48MHz clock...  the USB portion of your PIC must operate at that speed, the main controller can operate at lower speed...&lt;br /&gt;** Your PIC must response to PC initial queries (&lt;span style="font-style: italic;"&gt;also called USB enumeration&lt;/span&gt;) to exhange various information in order for windows to recognise the device and use it...&lt;br /&gt;** Your PIC USB portion must have what's called VendorID and ProductID in order for windows to manage USB communication destined for your device...&lt;br /&gt;&lt;br /&gt;I was ready to give up and revert back to my convenient RS-232 interface (&lt;span style="font-style: italic;"&gt;via USB to serial converter&lt;/span&gt;) but decided to dwell into USB for learning sake.  To avoid having to write my own device driver, I decided to use the HID (&lt;span style="font-style: italic;"&gt;Human Interface Device&lt;/span&gt;) class.  Windows (&lt;span style="font-style: italic;"&gt;and MacOS&lt;/span&gt;) already have driver for HID class so windows will detect the device, install the driver and I'm ready to go.  Sound simple eh...  &lt;span style="font-style: italic;"&gt;wait for the next installment of blog... &lt;/span&gt;:-)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;If up to this stage, you still have braincells to waste...&lt;/span&gt; &lt;span style="font-style: italic;"&gt;go on to these sites for more indepth info on USB...&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.beyondlogic.org/usbnutshell/"&gt;USB at BeyondLogic.com&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.at91.com/repFichier/Document-123/USB-tutorial.ppt"&gt;Or something from Atmel&lt;/a&gt;&lt;br /&gt;&lt;a href="http://varun.accosted.net/downloads/pdf/mobile/USB.pdf"&gt;Or something else here...&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4892396803005721414?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4892396803005721414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4892396803005721414' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4892396803005721414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4892396803005721414'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2009/06/usb-communication.html' title='USB Communication...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-7167968823469764441</id><published>2009-06-26T00:10:00.000-07:00</published><updated>2009-06-26T00:37:22.919-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPI Tutorial'/><title type='text'>SPI Tutorial</title><content type='html'>It is intended for transmission of data from a master device to/from one or more slave devices over short distances at high speeds (MHz).&lt;br /&gt;&lt;br /&gt;It is simply based on an 8 bit shift register shifting data out on a single pin and shifting data in on another pin.&lt;br /&gt;&lt;br /&gt;Note: some devices use more than 8 bits!&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Its main use is to replace parallel interfaces so you don't have to route parallel buses around a pcb.  pic spi masterFor example you can buy an SPI 12bit ADC and instead of 12 parallel wires to read the data you only need 4 SPI connections.  Actually you may only need three as you may not need to send data to the device!&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR1aXT7wfI/AAAAAAAAAFI/IZ6IhtNTb_E/s1600-h/spi-interface-master.png"&gt;&lt;img style="cursor: pointer; width: 250px; height: 117px;" src="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR1aXT7wfI/AAAAAAAAAFI/IZ6IhtNTb_E/s400/spi-interface-master.png" alt="" id="BLOGGER_PHOTO_ID_5351531353017663986" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;With the SPI interface you can communicate with a device transmitting and receiving 8 bits of data at the same time and it is suited to high speed streaming data transfers.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR122WHBnI/AAAAAAAAAFQ/iFcWvQyXogM/s1600-h/spi-interface-slave.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 250px; height: 117px;" src="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR122WHBnI/AAAAAAAAAFQ/iFcWvQyXogM/s400/spi-interface-slave.png" alt="" id="BLOGGER_PHOTO_ID_5351531842384627314" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Note: The trade o&lt;/span&gt;&lt;span style="font-style: italic;"&gt;ff between usingpic spi slave a parallel interface and the SPI interface is speed e.g. if you read a parallel 12bit ADC&lt;/span&gt;&lt;span style="font-style: italic;"&gt; at 200ksps then you could read the device at a 200kHz rate but if you want to get the same data rate using SPI then you need a ser&lt;/span&gt;&lt;span style="font-style: italic;"&gt;ial speed of 200kHz x 12 = 2.4MHz.  So the actual trade off is speed and the consequential noise introduced into the circuit.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Unlike I2C there is no concept of transferring ownership of the bus i.e. changing bus master and there are no slave device addresses.  SPI is a much simpler protocol and because of this you can operate it at speeds greater than 10MHz (compared with the 3.4MHz maximum for I2C).&lt;br /&gt;&lt;br /&gt;The best feature of SPI is that you can do full duplex data transfers (data in both directions at the same time) which you can not do with I2C and you can do it fast.&lt;br /&gt;&lt;br /&gt;Note: The maximum rate for a PIC Micro using a 20MHz clock is 5MHz.&lt;br /&gt;SPI Interface : Signals&lt;br /&gt;SPI Interface Signals&lt;br /&gt;PIC name  Master  Slave&lt;br /&gt;SCK  Serial clock output from master [SCK]  Input to slave [SCK]&lt;br /&gt;SDO  Serial data output from master [MOSI]  Input to slave [MOSI}&lt;br /&gt;SDI  Serial data input from slave [MISO]  Output from slave [MISO]&lt;br /&gt;SS  Optional slave (chip) select [SS]&lt;br /&gt; Slave select [SS]&lt;br /&gt;&lt;br /&gt;[] denotes SPI naming convention&lt;br /&gt;&lt;br /&gt;Here is the setup for a single SPI device connection:&lt;br /&gt;&lt;br /&gt;SPI Interface - single device&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Single SPI device&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR25gHOv3I/AAAAAAAAAFg/ovixRvLF7Wc/s1600-h/spi-interface-single.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 94px;" src="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR25gHOv3I/AAAAAAAAAFg/ovixRvLF7Wc/s400/spi-interface-single.png" alt="" id="BLOGGER_PHOTO_ID_5351532987467874162" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Note: The chip select signal SS is optional for a single device system as you could tie the SS input at the slave low if the other lines are dedicated to SPI use.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two ways to implement multiple slave operation:&lt;br /&gt;&lt;br /&gt;* Use a separate chip select for each slave device.&lt;br /&gt;* Wire all the slaves together DataOut to DataIn (daisy chain).&lt;br /&gt;&lt;br /&gt;SII Interface : Using chip selects&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SPI Interface using separate chip selects&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR3vZvNxqI/AAAAAAAAAFo/QyM_dLk2O9o/s1600-h/spi-interface-multi-cs.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 322px;" src="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR3vZvNxqI/AAAAAAAAAFo/QyM_dLk2O9o/s400/spi-interface-multi-cs.png" alt="" id="BLOGGER_PHOTO_ID_5351533913469470370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With this scheme you control each slave device using its chip select line (usually active low- red arrows show control lines).  When disabled the Data output from the slave goes into a high impedance state so it does not interfere with the currently selected slave and the data input is ignored (check datasheet).&lt;br /&gt;&lt;br /&gt;The advantage of this scheme is that you can consider each device separately when you compare it with the daisy chain method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SPI Interface : Daisy chaining&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SPI interface with daisy chain&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR4Y2vnaDI/AAAAAAAAAFw/ZriP1TNWQok/s1600-h/spi-interface-multi-daisy.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 331px;" src="http://1.bp.blogspot.com/_jMzsrLusGK0/SkR4Y2vnaDI/AAAAAAAAAFw/ZriP1TNWQok/s400/spi-interface-multi-daisy.png" alt="" id="BLOGGER_PHOTO_ID_5351534625630414898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With this scheme all data sent by the master is shifted into all devices and all data sent from each device is shifted out to the next (shown by red dotted arrow).  For this scheme to work  you have to make sure that each slave uses the clock in the same way (see clock and data) and you have to get the right number of bits - so there is more work to do in software.&lt;br /&gt;&lt;br /&gt;Compared to I2C these are very inelegant slave selection mechanisms and look like kludges to get round the fact that SPI was designed really as a simple single master to single slave protocol.  Having said that the above methods will work but for daisy chaining you will have to be careful of clock polarity and clock use as this is not defined in the SPI standard.&lt;br /&gt;SPI Interface : Clock and Data&lt;br /&gt;How a device reacts to clock input is undefined!!!&lt;br /&gt;&lt;br /&gt;Data can be sampled at the rising or falling edge and data can be generated after the rising or falling edge!&lt;br /&gt;&lt;br /&gt;This is why you can set the clock output from a master mode device in multiple ways just look at the diagram below - the first four signals are the four options you have to select the output clock.&lt;br /&gt;&lt;br /&gt;SPI Interface PIC signals (extract from DS39582B)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PIC SPI interface signals&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR6NQIfzFI/AAAAAAAAAF4/SYQ8muZv76E/s1600-h/spi-interface-pic-signals.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 331px;" src="http://3.bp.blogspot.com/_jMzsrLusGK0/SkR6NQIfzFI/AAAAAAAAAF4/SYQ8muZv76E/s400/spi-interface-pic-signals.png" alt="" id="BLOGGER_PHOTO_ID_5351536625310485586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You match the output clock to the clock that your device requires.&lt;br /&gt;&lt;br /&gt;Note: This is why daisy chaining may not be a good idea (or you have to think very carefully about it!).&lt;br /&gt;&lt;br /&gt;Note: For Master or Slave mode when using PICs you need to set the TRIS direction of the SCK pin appropriately.&lt;br /&gt;Problems with the SPI interface&lt;br /&gt;&lt;br /&gt;* The clock scheme may not be the same between devices.&lt;br /&gt;* The data length can vary from device to device.&lt;br /&gt;&lt;br /&gt;Advantages of the SPI interface&lt;br /&gt;&lt;br /&gt;* Very fast &gt; 10Mhz.&lt;br /&gt;* Simple protocol (easy to program in software if you have no SPI hardware module).&lt;br /&gt;* Simple interface (no bidirectional pins c.f. I2C).&lt;br /&gt;* Supports full duplex data streaming.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-style: italic;"&gt;&gt;&gt;&gt;&gt; extracted from http://www.best-microcontroller-projects.com/spi-interface.html&lt;&lt;&lt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-7167968823469764441?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/7167968823469764441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=7167968823469764441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7167968823469764441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7167968823469764441'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2009/06/spi-tutorial.html' title='SPI Tutorial'/><author><name>9w2dtr</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_jMzsrLusGK0/SkR1aXT7wfI/AAAAAAAAAFI/IZ6IhtNTb_E/s72-c/spi-interface-master.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3914035969236145302</id><published>2009-06-25T18:15:00.000-07:00</published><updated>2009-06-25T18:34:55.151-07:00</updated><title type='text'>Wireless System Development</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/SkQhZkGkWoI/AAAAAAAAAxw/AtWvdr1rDjc/s1600-h/Wireless+Overview.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 217px;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/SkQhZkGkWoI/AAAAAAAAAxw/AtWvdr1rDjc/s320/Wireless+Overview.JPG" alt="" id="BLOGGER_PHOTO_ID_5351438980294662786" border="0" /&gt;&lt;/a&gt;Over the next few weeks, we are going to develop a wireless system to capture and log data from remotes sensors.  The system will have a master controller to manage the communication between all the devices (nodes) in the system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Depicted above is the overall architecture and the communication mode.&lt;/span&gt;&lt;br /&gt;The PC will be communicating with the master controller (mPIC) via the USB interface.&lt;br /&gt;The master controller (mPIC) will be talking to the wireless module (RFM) via SPI interface.&lt;br /&gt;The wireless module (RFM) will communicate wireless to another RFM using radio waves at 430MHz.&lt;br /&gt;The slave (sPIC) will be talking to the RFM via SPI to receive commands and submit data.&lt;br /&gt;The slave (sPIC) will be connected to various analog and digital sensors as required.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;System general info.&lt;/span&gt;&lt;br /&gt;The slave will be operating using batteries thus will be in sleep mode until communication/data capture is required.&lt;br /&gt;The master controller will operate autonomously independent of the PC.  The PC connection is required only for offloading of capture data for further storage or analysis as well as for initial setup and configuration of the system.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3914035969236145302?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3914035969236145302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3914035969236145302' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3914035969236145302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3914035969236145302'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2009/06/wireless-system-development.html' title='Wireless System Development'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/SkQhZkGkWoI/AAAAAAAAAxw/AtWvdr1rDjc/s72-c/Wireless+Overview.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-8785099083728887845</id><published>2009-06-23T22:35:00.000-07:00</published><updated>2009-06-23T22:49:37.341-07:00</updated><title type='text'>SPI Communication...</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/SkG8QnWPLkI/AAAAAAAAAwI/NC-7kcuY7qc/s1600-h/350px-SPI_three_slaves.svg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 350px; height: 278px;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/SkG8QnWPLkI/AAAAAAAAAwI/NC-7kcuY7qc/s400/350px-SPI_three_slaves.svg.png" alt="" id="BLOGGER_PHOTO_ID_5350764825919041090" border="0" /&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;As per &lt;/span&gt;&lt;a style="color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus"&gt;Wikipedia&lt;/a&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;... &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt;(click link for extensive explanation)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt;"The &lt;/span&gt;&lt;b style="font-style: italic; color: rgb(0, 0, 0);"&gt;Serial Peripheral Interface Bus&lt;/b&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; or &lt;/span&gt;&lt;b style="font-style: italic; color: rgb(0, 0, 0);"&gt;SPI&lt;/b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; (often pronounced "es-pē-ī" [IPA: ɛs pi: 'aɪ] or "spy" [IPA: spaɪ]) bus is a &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Synchronous" title="Synchronous" class="mw-redirect"&gt;synchronous&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Serial_communications" title="Serial communications" class="mw-redirect"&gt;serial data link&lt;/a&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; standard named by &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Motorola" title="Motorola"&gt;Motorola&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; that operates in &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Full_duplex" title="Full duplex" class="mw-redirect"&gt;full duplex&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; mode. Devices communicate in &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Master-slave_%28technology%29" title="Master-slave (technology)"&gt;master/slave&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; mode where the master device initiates the &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Data_frame" title="Data frame" class="mw-redirect"&gt;data frame&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt;. Multiple slave devices are allowed with individual &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Slave_select" title="Slave select" class="mw-redirect"&gt;slave select&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt; (chip select) lines. Sometimes SPI is called a "four wire" serial bus, contrasting with &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#3-Wire_Serial_Buses" title="Serial Peripheral Interface Bus"&gt;three&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt;, &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/I2C" title="I2C" class="mw-redirect"&gt;two&lt;/a&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 0);"&gt;, and &lt;/span&gt;&lt;a style="font-style: italic; color: rgb(0, 0, 0);" href="http://en.wikipedia.org/wiki/1-Wire" title="1-Wire"&gt;one wire&lt;/a&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; serial buses."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Another good introduction to SPI (PDF) by &lt;a href="http://ww1.microchip.com/downloads/en/devicedoc/spi.pdf"&gt;Microchip&lt;/a&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;We are dwelling into USB, SPI and UART because we ourselves are learning on how to design and build a system comprising of various sensors reporting/logging data to a central host.  We'll be using &lt;a href="http://www.hoperf.com/pro/RF12B.html"&gt;Hope RF Transceiver Modules&lt;/a&gt; for wireless communication and the central host will be communicating with a PC via USB interface...  A good write up explaining the transceiver module is &lt;a href="http://blog.everythingrobotics.com/2008/01/08/rfm12-tutorial-part1/"&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-8785099083728887845?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/8785099083728887845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=8785099083728887845' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8785099083728887845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8785099083728887845'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2009/06/spi-communication.html' title='SPI Communication...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/SkG8QnWPLkI/AAAAAAAAAwI/NC-7kcuY7qc/s72-c/350px-SPI_three_slaves.svg.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-206548577649897474</id><published>2009-06-22T19:57:00.000-07:00</published><updated>2009-06-22T20:51:36.769-07:00</updated><title type='text'>After a long break...</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/SkBRQ6TkmkI/AAAAAAAAAvo/Wgq1ZkuAgC0/s1600-h/stay_tuned.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 152px;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/SkBRQ6TkmkI/AAAAAAAAAvo/Wgq1ZkuAgC0/s200/stay_tuned.jpg" alt="" id="BLOGGER_PHOTO_ID_5350365708287253058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Very soon, we'll start getting some activities back to this site...  some of the areas to be covered will be...&lt;br /&gt;... USB communications&lt;br /&gt;... SPI communications&lt;br /&gt;... UART communications&lt;br /&gt;&lt;br /&gt;We'll look at the physical aspect as well as the logical/firmware aspects to the devices talking to each other... stay tune...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-206548577649897474?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/206548577649897474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=206548577649897474' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/206548577649897474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/206548577649897474'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2009/06/after-long-break.html' title='After a long break...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_tMtO23Q5vm4/SkBRQ6TkmkI/AAAAAAAAAvo/Wgq1ZkuAgC0/s72-c/stay_tuned.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6535861509957960324</id><published>2008-08-26T06:24:00.000-07:00</published><updated>2008-10-07T19:34:57.432-07:00</updated><title type='text'>switch() case default</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Lesson 6.2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Now the other way to make decisions is to use the switch() case statement.&lt;br /&gt;&lt;br /&gt;The format is&lt;br /&gt;switch(expression); {&lt;br /&gt;case const value: syntax to execute; break;&lt;br /&gt;default:  syntax to execute; break;&lt;br /&gt;}&lt;br /&gt;Here is an example:-&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;&lt;img src="http://3.bp.blogspot.com/_ZoRUv8L3D60/SNuHrajQQrI/AAAAAAAAAZQ/ZjC1pU37qKM/s320/L62.gif" /&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;When cnt is 1 the text One is displayed on the lcd.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;When cnt is 2 the text Two and Three is displayed on the lcd. This is because, case 2, does not have a break, so it continues processing the next line.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;When cnt is 3, Three is displayed on lcd. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;When cnt is 4 or more unknown is displayed on lcd.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;Note: The switch value can only be integer or char.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;With case the break is important as illustrated in case 2 in the above example. So be sure to code correctly or you might get undesired results.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Note: default is optional. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6535861509957960324?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6535861509957960324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6535861509957960324' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6535861509957960324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6535861509957960324'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/08/switch-case-default.html' title='switch() case default'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_ZoRUv8L3D60/SNuHrajQQrI/AAAAAAAAAZQ/ZjC1pU37qKM/s72-c/L62.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4732164777454290772</id><published>2008-07-07T00:45:00.000-07:00</published><updated>2008-07-07T01:06:11.470-07:00</updated><title type='text'>IF</title><content type='html'>&lt;!--[if !mso]&gt; &lt;style&gt; v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} &lt;/style&gt; &lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;o:officedocumentsettings&gt;   &lt;o:allowpng/&gt;  &lt;/o:OfficeDocumentSettings&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;   &lt;/w:Compatibility&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:Wingdings;  panose-1:5 0 0 0 0 0 0 0 0 0;  mso-font-charset:2;  mso-generic-font-family:auto;  mso-font-pitch:variable;  mso-font-signature:0 268435456 0 0 -2147483648 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";} @page Section1  {size:595.45pt 841.7pt;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;}  /* List Definitions */  @list l0  {mso-list-id:1821997574;  mso-list-template-ids:26378338;} @list l0:level1  {mso-level-number-format:bullet;  mso-level-text:;  mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;  mso-ansi-font-size:10.0pt;  font-family:Symbol;} ol  {margin-bottom:0in;} ul  {margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:"Table Normal";  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-parent:"";  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:"Times New Roman";} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;u&gt;Lesson 6.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;Making decisions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;At some point of your program, you will need to make a decision on what to do when a certain value is achieved or not achieved. By doing this in your program, you will be changing the program flow. In C, there are 3 way to make decision.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Usage:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;if (expression) statem&lt;/b&gt;&lt;b style=""&gt;ent 1 [else statement 2]&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;/blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Statement 1 will only be executed if the expression is &lt;b style=""&gt;true (non 0).&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;And the &lt;b style=""&gt;optional&lt;/b&gt; else if specified will be executed if &lt;b style=""&gt;expression is false&lt;/b&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;if () usage example.&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_ZoRUv8L3D60/SHHN_XDDrrI/AAAAAAAAAXM/jc_tK-BGLeo/s1600-h/L6a.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_ZoRUv8L3D60/SHHN_XDDrrI/AAAAAAAAAXM/jc_tK-BGLeo/s400/L6a.jpg" alt="" id="BLOGGER_PHOTO_ID_5220179931501407922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;i style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Though the usage of &lt;b style=""&gt;{ }&lt;/b&gt; is optional for a &lt;b style=""&gt;single&lt;/b&gt; statement following if or else, I recommend using it. Indentation of &lt;b style=""&gt;if()&lt;/b&gt; is recommended, so that it is easier to debug, understand the program flow and read the code.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_ZoRUv8L3D60/SHHN_YO5d2I/AAAAAAAAAXU/xaVCnQGkaWM/s1600-h/L6b.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_ZoRUv8L3D60/SHHN_YO5d2I/AAAAAAAAAXU/xaVCnQGkaWM/s400/L6b.jpg" alt="" id="BLOGGER_PHOTO_ID_5220179931819505506" border="0" /&gt;&lt;/a&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;The code above can be rewritten.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_ZoRUv8L3D60/SHHN_rYbsHI/AAAAAAAAAXc/Vu489zcV104/s1600-h/L6c.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_ZoRUv8L3D60/SHHN_rYbsHI/AAAAAAAAAXc/Vu489zcV104/s400/L6c.jpg" alt="" id="BLOGGER_PHOTO_ID_5220179936959770738" border="0" /&gt;&lt;/a&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The end result will be the same. It up to your programming style.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Nested if()&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Nested if() is nothing more that if within if within if….Good example is lesson 4 porgram v1. When any one if () is true, executes the code for it and exits the nested if(). But be careful. When using nested if() you have to adhere to &lt;b style=""&gt;PIC&lt;/b&gt; nesting &lt;b style=""&gt;limitation&lt;/b&gt; as to how many levels of nested calls you can make, which is as stated below:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Maximum nested calls.&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;8 calls for PIC12 family, &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;8 calls for PIC16 family, &lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;31 calls for PIC18 family.&lt;/li&gt;&lt;/ul&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Example.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:414.75pt;"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" title="nesetd%20if"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_ZoRUv8L3D60/SHHKHBMqBuI/AAAAAAAAAXE/EKFarz6vECw/s1600-h/L6+Nested+if.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp1.blogger.com/_ZoRUv8L3D60/SHHKHBMqBuI/AAAAAAAAAXE/EKFarz6vECw/s400/L6+Nested+if.jpg" alt="" id="BLOGGER_PHOTO_ID_5220175665028531938" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;As you can see, it can get quite complicated. And is usually the source of many errors. Proper indentation helps make the code more readable. But use with care. This is just a simple example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4732164777454290772?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4732164777454290772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4732164777454290772' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4732164777454290772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4732164777454290772'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/07/if.html' title='IF'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_ZoRUv8L3D60/SHHN_XDDrrI/AAAAAAAAAXM/jc_tK-BGLeo/s72-c/L6a.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4645398607511303122</id><published>2008-06-24T07:02:00.000-07:00</published><updated>2008-07-07T01:10:23.470-07:00</updated><title type='text'>Base n</title><content type='html'>&lt;p id="brnk6" class="MsoNormal"&gt;&lt;b id="brnk7"&gt;Counting. &lt;/b&gt;&lt;/p&gt;&lt;b id="brnk7"&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk9" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk11" class="MsoNormal"&gt;The numbers we use everyday are known &lt;b id="brnk12"&gt;decimal numbers&lt;/b&gt; or &lt;b id="brnk13"&gt;base 10&lt;/b&gt;. Meaning there are 10 numbers ranging from 0 to 9. This translate to &lt;b id="brnk14"&gt;10&lt;sup id="brnk15"&gt;3&lt;/sup&gt; 10&lt;sup id="brnk16"&gt;2&lt;/sup&gt; 10&lt;sup id="brnk17"&gt;1&lt;/sup&gt; 10&lt;sup id="brnk18"&gt;0  &lt;/sup&gt;&lt;/b&gt;or 1000 100 10 1. So to write number 205, will be same as (1000x0)+(100x2)+(10x0)+(1x5) = 205.Or you can get the same result by division. Remainder is written on the right. Results read from bottom up. I know you know all this, but it just to refresh your memory. &lt;/p&gt;    &lt;p id="brnk22" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p id="brnk26" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div id="mvyx" style="text-align: center;"&gt;&lt;div id="eq.g" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="mvyx0" style="width: 115px; height: 109px;" src="http://docs.google.com/File?id=ddbg2pgw_57f8p33hhr_b" /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;p id="brnk26" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p id="brnk26" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p id="brnk26" class="MsoNormal"&gt;&lt;/p&gt;Now for the fun stuff.&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk27" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk29" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk31" class="MsoNormal"&gt;&lt;b id="brnk32"&gt;Base 2&lt;/b&gt;&lt;/p&gt;&lt;b id="brnk32"&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk34" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk36" class="MsoNormal"&gt;In base 2 (&lt;b id="brnk37"&gt;BINARY&lt;/b&gt;), only 2 numbers are available for use. They are 0 and 1. &lt;/p&gt;  &lt;p id="brnk38" class="MsoNormal"&gt;2&lt;sup id="brnk39"&gt;7&lt;/sup&gt; 2&lt;sup id="brnk40"&gt;6&lt;/sup&gt; 2&lt;sup id="brnk41"&gt;5&lt;/sup&gt; 2&lt;sup id="brnk42"&gt;4&lt;/sup&gt; 2&lt;sup id="brnk43"&gt;3&lt;/sup&gt; 2&lt;sup id="brnk44"&gt;2&lt;/sup&gt; 2&lt;sup id="brnk45"&gt;1&lt;/sup&gt; 2&lt;sup id="brnk46"&gt;0.  &lt;/sup&gt;Which translates to 128 64 32 16 8 4 2 1. So to represent 205&lt;sub id="brnk48"&gt;10&lt;/sub&gt; we will need (128x1)+(64x1)+(32x0)+(16x0)+(8x1)+(4x1)+(2x0)+(1x1). Which translate to 11001101. There is an easier method of doing this, division by 2. &lt;/p&gt;  &lt;p id="brnk49" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk51" class="MsoNormal"&gt; &lt;/p&gt;&lt;div id="g3yc" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="jjnn" style="width: 156px; height: 201px;" src="http://docs.google.com/File?id=ddbg2pgw_58cwxc22d3_b" /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk53" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p id="brnk55" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk57" class="MsoNormal"&gt;So now eight base 2 numbers are used, that is to say 8 bits (&lt;b id="brnk58"&gt;BI&lt;/b&gt;nary digi&lt;b id="brnk59"&gt;TS&lt;/b&gt;).&lt;/p&gt;  &lt;p id="brnk60" class="MsoNormal"&gt;Remainder is written on the right. The answer is read from bottom up. The number is written as 11001101&lt;sub id="brnk61"&gt;2 &lt;/sub&gt;and in MikroC is written as 0b11001101&lt;sub id="brnk62"&gt;. &lt;/sub&gt;&lt;b id="brnk63"&gt;All binary numbers are represented by 0b prefix&lt;/b&gt;. Simple isn’t it?  For results with less than 8 bits, zeros are placed on the left of the answer until the bits count is 8. ie. result is 1100. Then result 00001100. Also good to know is that the &lt;b id="brnk65"&gt;&lt;span id="brnk66"  style="color:red;"&gt;leftmost 4 bits are known as high order bits&lt;/span&gt; and &lt;span id="brnk67" style="color: rgb(255, 102, 0);"&gt;the rightmost 4 bits are known as low order bits&lt;/span&gt;.&lt;/b&gt; &lt;/p&gt;  &lt;p id="brnk68" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk70" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk72" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk74" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk76" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk78" class="MsoNormal"&gt;&lt;b id="brnk79"&gt;&lt;u id="brnk80"&gt;Some useful info.&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;b id="brnk79"&gt;&lt;u id="brnk80"&gt;&lt;/u&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk82" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk84" class="MsoNormal"&gt;4 bits = 1 nibble &lt;/p&gt;  &lt;p id="brnk85" class="MsoNormal"&gt;8 bits = 1 byte &lt;/p&gt;  &lt;p id="brnk86" class="MsoNormal"&gt;16 bits = 1 word&lt;/p&gt;  &lt;p id="brnk87" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk89" class="MsoNormal"&gt;&lt;b id="brnk90"&gt;Base 8.&lt;/b&gt;&lt;/p&gt;&lt;b id="brnk90"&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk92" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk94" class="MsoNormal"&gt;Base 8 is known as &lt;b id="brnk95"&gt;OCTAL&lt;/b&gt;. The process of converting base 10 to base 8 is similar to the above example except you divide with 8. So lets convert 205&lt;sub id="brnk96"&gt;10 to&lt;/sub&gt; base 8. &lt;/p&gt;  &lt;p id="brnk98" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk100" class="MsoNormal"&gt; &lt;/p&gt;&lt;div id="e50-" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="jjnn0" style="width: 88px; height: 76px;" src="http://docs.google.com/File?id=ddbg2pgw_59fk79jzdq_b" /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk102" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p id="brnk104" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk106" class="MsoNormal"&gt;The answer is 315&lt;sub id="brnk107"&gt;8&lt;/sub&gt; and octal numbers are represented in MikroE C by preceding the number with 0 (zero), which will be written as 0315. This number can be reversed to base 10 by 8&lt;sup id="brnk108"&gt;2&lt;/sup&gt; 8&lt;sup id="brnk109"&gt;1&lt;/sup&gt; 8&lt;sup id="brnk110"&gt;0 &lt;/sup&gt;which is 64 8 1. So (64 x 3) + (8 x 1) + (1 x 5) = 205.&lt;/p&gt;  &lt;p id="brnk111" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk113" class="MsoNormal"&gt;&lt;b id="brnk114"&gt;Base 16&lt;/b&gt;&lt;/p&gt;&lt;b id="brnk114"&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk116" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk118" class="MsoNormal"&gt;In base 16, known as &lt;b id="brnk119"&gt;HEX&lt;/b&gt;, numbers 0 to 9 and letters A to F are used to represent the number. Because we cannot use a double digit number like 11,12 and so forth, the letters A to F is used to represent a double digit number, A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Let’s convert 205&lt;sub id="brnk120"&gt;10&lt;/sub&gt; to hex by dividing.&lt;/p&gt;  &lt;p id="brnk121" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk123" class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p id="brnk125" class="MsoNormal"&gt;&lt;/p&gt;&lt;div id="dp:i" style="padding: 1em 0pt; text-align: left;"&gt;&lt;img id="u.50" style="width: 105px; height: 80px;" src="http://docs.google.com/File?id=ddbg2pgw_60gqsg6bgc_b" /&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk127" class="MsoNormal"&gt;As you can see, we cannot write 12 and 13. So we change the number to their alphabet equivalent. So the answer will be &lt;b id="brnk128"&gt;BC&lt;sub id="brnk129"&gt;16&lt;/sub&gt;&lt;/b&gt;. Again we can verify if the answer is correct by using the 16&lt;sup id="brnk130"&gt;1&lt;/sup&gt; 16&lt;sup id="brnk131"&gt;0&lt;/sup&gt;. Which is 16 and 1. We know that B is 12 and C is 13, so (16 x 12) + (1 x 13) which gives us a decimal 205. Hex number is represented as 0xnn in MikroC. Our number will be written as &lt;b id="brnk132"&gt;0xBC&lt;/b&gt;. The 0x tells the compiler that the next digits are hex number. If the division yields only one number, than a 0 precedes the number. ie. 0x0B.  &lt;/p&gt;  &lt;p id="brnk134" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk136" class="MsoNormal"&gt;That’s all there is to understanding base n. To convert a number from base 8 to base 2, firstly the number needs to be converted to base 10 then to base 2. There no calculation method to directly convert the number. I will present you later with the table to do exactly that.&lt;/p&gt;  &lt;p id="brnk137" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk139" class="MsoNormal"&gt;Lets do some exercise so that base n sticks in our minds.&lt;/p&gt;  &lt;p id="brnk140" class="MsoNormal"&gt; &lt;/p&gt;  &lt;span id="brnk142" style=";font-family:&amp;quot;;" &gt;  &lt;/span&gt;  &lt;p id="brnk144" class="MsoNormal"&gt;&lt;b id="brnk145"&gt;Skill check Lesson 5.&lt;/b&gt;&lt;/p&gt;&lt;b id="brnk145"&gt;&lt;/b&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk147" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk149" class="MsoNormal"&gt;1. Convert to binary.&lt;/p&gt;  &lt;p id="brnk150" class="MsoNormal"&gt;a. 10&lt;sub id="brnk151"&gt;10&lt;/sub&gt;                          b. 255&lt;sub id="brnk153"&gt;10&lt;/sub&gt;                        c. 101&lt;sub id="brnk155"&gt;10&lt;/sub&gt;                        d.  68&lt;sub id="brnk158"&gt;10&lt;/sub&gt;&lt;/p&gt;  &lt;p id="brnk159" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk161" class="MsoNormal"&gt;2. Convert to decimal.&lt;/p&gt;  &lt;p id="brnk162" class="MsoNormal"&gt;a. 10101100&lt;sub id="brnk163"&gt;2&lt;/sub&gt;               b. 10010011&lt;sub id="brnk165"&gt;2&lt;/sub&gt;               c. 01101111&lt;sub id="brnk167"&gt;2&lt;/sub&gt;               d. 1001&lt;sub id="brnk169"&gt;2&lt;/sub&gt;&lt;/p&gt;  &lt;p id="brnk170" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk172" class="MsoNormal"&gt;3. Convert to octal.&lt;/p&gt;  &lt;p id="brnk173" class="MsoNormal"&gt;a. 252&lt;sub id="brnk174"&gt;10&lt;/sub&gt;                        b. 97&lt;sub id="brnk176"&gt;10&lt;/sub&gt;                          c. 18&lt;sub id="brnk178"&gt;10&lt;/sub&gt;                          d. 127&lt;sub id="brnk180"&gt;10&lt;/sub&gt;&lt;/p&gt;  &lt;p id="brnk181" class="MsoNormal"&gt; &lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk183" class="MsoNormal"&gt;4. Convert to hex.&lt;/p&gt;  &lt;p id="brnk184" class="MsoNormal"&gt;a. 255&lt;sub id="brnk185"&gt;10&lt;/sub&gt;                        b. 126&lt;sub id="brnk187"&gt;10&lt;/sub&gt;                        c. 160&lt;sub id="brnk189"&gt;10&lt;/sub&gt;                        d. 32&lt;sub id="brnk191"&gt;10&lt;/sub&gt;&lt;/p&gt;&lt;sub id="brnk191"&gt;&lt;/sub&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk193" class="MsoNormal"&gt;&lt;sub id="brnk194"&gt; &lt;/sub&gt;&lt;/p&gt;&lt;sub id="brnk194"&gt;&lt;/sub&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk196" class="MsoNormal"&gt;&lt;sub id="brnk197"&gt; &lt;/sub&gt;&lt;/p&gt;&lt;sub id="brnk197"&gt;&lt;/sub&gt;&lt;p&gt;&lt;/p&gt;  &lt;p id="brnk199" class="MsoNormal"&gt;You can post your answers in the comments. Chat box might get confusing.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4645398607511303122?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4645398607511303122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4645398607511303122' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4645398607511303122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4645398607511303122'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/06/counting.html' title='Base n'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-8627073586806970398</id><published>2008-05-20T18:11:00.000-07:00</published><updated>2008-05-20T18:16:12.404-07:00</updated><title type='text'>Character Arrays</title><content type='html'>&lt;p class="MsoNormal"&gt;Lesson 4.4&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;Characters and Character Arrays&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Storing characters is slightly different from storing numbers. You may have notice through out this lesson; I have hardly shown any character arrays. But you have already used it in the first lesson of LCD output. Characters in C are individual letters, numbers and special symbols. These characters are stored using 1 byte or 8 bits using the ASCII character value. So when I store the letter ‘A’ in a variable, C stores the ASCII code value of ‘A’, which is integer 65. So, it would be perfectly valid for me to do this in C:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;result = ‘A’ + 32;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Result will now be 97 decimal, which is ‘a’ ASCII. In C individual characters are stored like this:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char MenuOption[4] = {‘A’, ‘E’, ‘D’, ‘Q’};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Notice a single quotation mark ‘ is used. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When a collection of characters are stored in C, it is called a string and math operation like the example above cannot be preformed.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char callsign[6] = “9w2gu”;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This means, declare variable callsign of 6 elements long and initialize the variable with 9w2gu.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;9w2gu is only 5 characters why did I specify 6 elements? The compiler need to know when the string terminates, it does this by adding a ‘\0’, a NUL character, at the end of the string. Also a string declaration begins and ends with double quotation mark “, and string do not require the { } for single dimensional array. So take care when declaring strings.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To declare and initialize string variables 1D character array.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char callsign[] = “9W2DTR”; // let compiler find the size&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char handle[7] = ”Dexter”; //&lt;span style=""&gt;  &lt;/span&gt;max char handle is 6 1 for ’\0’ NUL&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To display the content of the string, just use the variable name. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;lcd_out(1,1,callsign);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Using a for loop will display each character at a time. Ex.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;lcd_out(1,1,callsign[pos]);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This is where the character array is different from numerical arrays.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;if char is declared as below, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;char callsign[6];&lt;/p&gt;  &lt;p class="MsoNormal"&gt;callsign = “9w2dtr”&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Will only print 9w2dt or undesired results, remember you need to specify space for NUL character too.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Below a visual sample of 1D character array.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div align="center"&gt;  &lt;table class="MsoTableGrid" style="border-style: outset inset inset outset; border-color: -moz-use-text-color; border-width: 1pt; margin-left: 138.7pt; width: 147px; height: 56px;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style="height: 31.15pt;"&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 139.1pt; height: 31.15pt;" valign="top" width="185"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;    &lt;v:stroke joinstyle="miter"&gt;    &lt;v:formulas&gt;     &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;     &lt;v:f eqn="sum @0 1 0"&gt;     &lt;v:f eqn="sum 0 0 @1"&gt;     &lt;v:f eqn="prod @2 1 2"&gt;     &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;     &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @0 0 1"&gt;     &lt;v:f eqn="prod @6 1 2"&gt;     &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;     &lt;v:f eqn="sum @8 21600 0"&gt;     &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @10 21600 0"&gt;    &lt;/v:formulas&gt;    &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;    &lt;o:lock ext="edit" aspectratio="t"&gt;   &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1027" type="#_x0000_t75" style="'width:128.25pt;"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" title="char%20array%201d"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ZoRUv8L3D60/SDN3N9FbtkI/AAAAAAAAATU/MMGLKeomF34/s1600-h/char+array+1d.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_ZoRUv8L3D60/SDN3N9FbtkI/AAAAAAAAATU/MMGLKeomF34/s320/char+array+1d.jpg" alt="" id="BLOGGER_PHOTO_ID_5202633076162410050" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Now for some explanation on 2 and 3 dimensional character array.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;They work similar to their numerical partners except the last element defines the width of the string field. Ex.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char dow[7][4] = {“Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”, “Sun”);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This means, create an array of 7 rows, 4 characters each. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Below the visual display of the above declared 2D array.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div align="center"&gt;&lt;div style="text-align: left;"&gt;  &lt;/div&gt;&lt;table class="MsoTableGrid" style="border-style: outset inset inset outset; border-color: -moz-use-text-color; border-width: 1pt; width: 75px; height: 120px;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style="height: 107.25pt;"&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 71.45pt; height: 107.25pt;" valign="top" width="95"&gt;&lt;div style="text-align: left;"&gt;   &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1026" type="#_x0000_t75" style="'width:59.25pt;height:104.25pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image002.jpg" title="char%20array%202d"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SDN3ONFbtlI/AAAAAAAAATc/k4tOJIHmCTM/s1600-h/char+array+2d.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SDN3ONFbtlI/AAAAAAAAATc/k4tOJIHmCTM/s320/char+array+2d.jpg" alt="" id="BLOGGER_PHOTO_ID_5202633080457377362" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p class="MsoNormal"&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;To display Friday I would need to specify the row element only. Example:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;lcd_out(1,1,dow[4]);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Will display Fri on the lcd.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Similarly, 3D character arrays work the same way.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;3D character array are declared as shown below.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char students[3][2][7] = &lt;/p&gt;  &lt;p class="MsoNormal"&gt;{“9w2bpy”, “Yau”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“9w2dtr”, “Dexter”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“9m2cf”, “Chow”};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Which will look like this.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border: medium none ; margin-left: 1.25in; border-collapse: collapse; width: 265px; height: 42px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style="height: 80.35pt;"&gt;   &lt;td style="border: 3pt groove windowtext; padding: 0in 5.4pt; width: 277.05pt; height: 80.35pt;" valign="top" width="369"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:266.25pt;height:90pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image003.jpg" title="char%20array%203d"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SDN3ONFbtmI/AAAAAAAAATk/Byj-Ug8Cni0/s1600-h/char+array+3d.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SDN3ONFbtmI/AAAAAAAAATk/Byj-Ug8Cni0/s320/char+array+3d.jpg" alt="" id="BLOGGER_PHOTO_ID_5202633080457377378" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This means declare a character array called students 3 rows 2 columns which can hold 7 characters each. Always remember to allocate space for the NUL character.&lt;span style=""&gt;  &lt;/span&gt;If I did this:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char students[3][2][7] = &lt;/p&gt;  &lt;p class="MsoNormal"&gt;{“9w2bpy”, “Yau”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“9w2dtr”, “Dexter”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“&lt;b style=""&gt;9m2cf”, “Uncle Chow&lt;/b&gt;”};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The complier will generate an error, because “Uncle Chow exceeds 7 characters.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Alternatively I could do this :-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char students[3][2]&lt;b style=""&gt;[] &lt;/b&gt;= &lt;/p&gt;  &lt;p class="MsoNormal"&gt;{“9w2bpy”, “Yau”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“9w2dtr”, “Dexter”, &lt;/p&gt;  &lt;p class="MsoNormal"&gt;“9m2cf”, “Uncle Chow”};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let the compiler check for the max length of string.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;lcd_out(1,1, students[1][0]); // will output 9w2dtr.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;lcd_out(1,1,students[0][1]); // will output Yau.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;So, important thing to remember is that character arrays is :-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Remember to allocate 1 extra character for NUL.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The last [] specifies number of characters.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;All arrays, be it character or numerical, elements number (the numbers between []), can only be unsigned integer (no negative and no decimal point values).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-8627073586806970398?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/8627073586806970398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=8627073586806970398' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8627073586806970398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8627073586806970398'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/05/character-arrays.html' title='Character Arrays'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_ZoRUv8L3D60/SDN3N9FbtkI/AAAAAAAAATU/MMGLKeomF34/s72-c/char+array+1d.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-1212806751534883091</id><published>2008-05-11T18:56:00.000-07:00</published><updated>2008-05-12T19:14:30.307-07:00</updated><title type='text'>Answers 4</title><content type='html'>&lt;b style=""&gt;Lesson 4 Skill Check Answers&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;  &lt;table class="MsoTableGrid" style="border: 1pt outset ; width: 308px; height: 592px;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;&lt;div style="text-align: center;"&gt;   &lt;/div&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;b style=""&gt;Q1&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCj5K9FbtcI/AAAAAAAAASU/s0FHO6An2kI/s1600-h/Answer+L4Q1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCj5K9FbtcI/AAAAAAAAASU/s0FHO6An2kI/s200/Answer+L4Q1.jpg" alt="" id="BLOGGER_PHOTO_ID_5199679736390596034" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;&lt;div style="text-align: center;"&gt;   &lt;/div&gt;&lt;p style="text-align: center;" class="MsoNormal"&gt;&lt;b style=""&gt;Q2a&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtXI/AAAAAAAAARs/p7sR207xfeA/s1600-h/Answer+L4Q2a.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtXI/AAAAAAAAARs/p7sR207xfeA/s200/Answer+L4Q2a.jpg" alt="" id="BLOGGER_PHOTO_ID_5199311129412351346" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b style=""&gt;Q2b&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtYI/AAAAAAAAAR0/23y9l0rz2NU/s1600-h/Answer+L4Q2b.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtYI/AAAAAAAAAR0/23y9l0rz2NU/s200/Answer+L4Q2b.jpg" alt="" id="BLOGGER_PHOTO_ID_5199311129412351362" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b style=""&gt;Q2c&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtZI/AAAAAAAAAR8/2HnDKNg7cmY/s1600-h/Answer+L4Q2c.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCep7NFbtZI/AAAAAAAAAR8/2HnDKNg7cmY/s200/Answer+L4Q2c.jpg" alt="" id="BLOGGER_PHOTO_ID_5199311129412351378" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b style=""&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCep7dFbtaI/AAAAAAAAASE/CW_wN5Xf6XU/s1600-h/Answer+L4Q3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCep7dFbtaI/AAAAAAAAASE/CW_wN5Xf6XU/s200/Answer+L4Q3.jpg" alt="" id="BLOGGER_PHOTO_ID_5199311133707318690" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b style=""&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt inset ; padding: 0in 5.4pt; width: 207pt;" valign="top" width="276"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCeqYtFbtbI/AAAAAAAAASM/AKhWHiR-LCE/s1600-h/Answer+L4Q4.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCeqYtFbtbI/AAAAAAAAASM/AKhWHiR-LCE/s200/Answer+L4Q4.jpg" alt="" id="BLOGGER_PHOTO_ID_5199311636218492338" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;These are sample code for common cathode.  All code using to display or blink the dot, can be XOR with 0x80 will on or off the dot regardless of of common anode or cathode.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-1212806751534883091?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/1212806751534883091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=1212806751534883091' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1212806751534883091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1212806751534883091'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/05/lesson-4-skill-check-answers-q1-q2a-q2b.html' title='Answers 4'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_ZoRUv8L3D60/SCj5K9FbtcI/AAAAAAAAASU/s0FHO6An2kI/s72-c/Answer+L4Q1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-1303037020280788264</id><published>2008-05-10T04:20:00.000-07:00</published><updated>2008-05-15T19:20:28.563-07:00</updated><title type='text'>Multidimensional Arrays</title><content type='html'>&lt;span style=""&gt;&lt;/span&gt;Lesson 4.2    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;u&gt;2 Dimensional (2D).&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;By now, you should have an understanding how arrays work. The element number points to the data stored. I will briefly now explain 2D and 3D arrays. These are known as multidimensional array. You can have as many dimensional as you need, but make sure you have enough memory to store them.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;o:p&gt;&lt;/o:p&gt;Let’s say I want to collect temperature reading in degrees C, 3 times a day, at dawn, &lt;st1:time hour="12" minute="0"&gt;noon&lt;/st1:time&gt; and dusk for 7 days. This is how I would declare my array:-  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;float TempC[7][3];&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This will look like a small spreadsheet. 2D arrays are reference in row and column format. So TempC will have 7 rows and 3 columns as illustrated in the diagram below.&lt;/p&gt;&lt;p class="MsoNormal"&gt;                             &lt;/p&gt;&lt;table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse; margin-left: 6.75pt; margin-right: 6.75pt; width: 184px; height: 10px;" align="left" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 3pt ridge windowtext; padding: 0in 5.4pt; width: 89.55pt;" valign="top" width="119"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;    &lt;v:stroke joinstyle="miter"&gt;    &lt;v:formulas&gt;     &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;     &lt;v:f eqn="sum @0 1 0"&gt;     &lt;v:f eqn="sum 0 0 @1"&gt;     &lt;v:f eqn="prod @2 1 2"&gt;     &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;     &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @0 0 1"&gt;     &lt;v:f eqn="prod @6 1 2"&gt;     &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;     &lt;v:f eqn="sum @8 21600 0"&gt;     &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @10 21600 0"&gt;    &lt;/v:formulas&gt;    &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;    &lt;o:lock ext="edit" aspectratio="t"&gt;   &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:78.75pt;"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" title="array7x3"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCWF_M8KdMI/AAAAAAAAAPc/wIavw1Qcs60/s1600-h/2D+array7x3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 105px; height: 137px;" src="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCWF_M8KdMI/AAAAAAAAAPc/wIavw1Qcs60/s320/2D+array7x3.jpg" alt="" id="BLOGGER_PHOTO_ID_5198708665720927426" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;            &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;I could also do this:- &lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;float TempC[3][7];&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;Which would look like:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border: medium none ; margin-left: 120.7pt; border-collapse: collapse; width: 485px; height: 25px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 3pt ridge windowtext; padding: 0in 5.4pt; width: 2.4in;" valign="top" width="230"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1028" type="#_x0000_t75" style="'width:156pt;height:52.5pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image016.jpg" title="array3x7"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCWG_88KdPI/AAAAAAAAAP0/ZBVpplFy9IM/s1600-h/2D+array3x7.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_ZoRUv8L3D60/SCWG_88KdPI/AAAAAAAAAP0/ZBVpplFy9IM/s320/2D+array3x7.jpg" alt="" id="BLOGGER_PHOTO_ID_5198709778117457138" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You can use any method as long as you take care in storing and accessing the data. It is the norm to use the first method.&lt;/p&gt;  &lt;span style=""&gt;  &lt;/span&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;No special attention is needed to initialize the array. I would do the following for easier reading.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;table class="MsoTableGrid" style="border: medium none ; margin-left: 102pt; border-collapse: collapse; width: 285px; height: 190px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 89.4pt;" valign="top" width="119"&gt;               &lt;p class="MsoNormal"&gt;int table[4][3] =&lt;br /&gt;{1, 2, 3,&lt;br /&gt;2, 4, 6,&lt;br /&gt;3, 6, 9,&lt;br /&gt;4, 8, 12};&lt;/p&gt;      &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;It just makes it easier to understand the way the data in the array is stored. It would not be wrong to do this:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;int table[4][3] = {1, 2, 3, 2, 4, 6, 3, 6, 9, 4, 8, 12}; &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;if I wanted to print the array on lcd:-&lt;/p&gt;&lt;p class="MsoNormal"&gt;  &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;blockquote&gt;       &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCWKyc8KdRI/AAAAAAAAAQE/w-BzMjDhzAw/s1600-h/Example+42+1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCWKyc8KdRI/AAAAAAAAAQE/w-BzMjDhzAw/s320/Example+42+1.jpg" alt="" id="BLOGGER_PHOTO_ID_5198713944235734290" border="0" /&gt;&lt;/a&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;p class="MsoNormal"&gt;Lesson 4.3&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;3D&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Now I want to record temperature 3 times a day morning, &lt;st1:time hour="12" minute="0"&gt;noon&lt;/st1:time&gt; and dusk; for the whole year. I could declare the array as float TempC[365][3]. This way I would not know the month and date the temperature is recorded for. A better way to do this would be float TempC[12][31][3], which would look like:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="margin-left: 127.45pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 161.4pt;" valign="top" width="215"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1029" type="#_x0000_t75" style="'width:147.75pt;height:129.75pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image017.jpg" title="3D"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCWHAM8KdQI/AAAAAAAAAP8/D2gZpgclyS4/s1600-h/3D.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_ZoRUv8L3D60/SCWHAM8KdQI/AAAAAAAAAP8/D2gZpgclyS4/s320/3D.jpg" alt="" id="BLOGGER_PHOTO_ID_5198709782412424450" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Looks confusing? Let me explain,&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Each row from 0 to 11 is month which is [12];&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Each alternate color column is day which is [31];&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Each day column (0, 1 and&lt;span style=""&gt;  &lt;/span&gt;2) is time of day the temperature is recoded is [3].&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To store / and retrieve data from 3D array:&lt;/p&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCWLtc8KdSI/AAAAAAAAAQM/qF49WhLGlKc/s1600-h/Example+42+2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_ZoRUv8L3D60/SCWLtc8KdSI/AAAAAAAAAQM/qF49WhLGlKc/s320/Example+42+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5198714957848016162" border="0" /&gt;&lt;/a&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You can have as many dimensions that you need, but must take care of how much memory you have available. Example if you have an array of&lt;span style=""&gt;  &lt;/span&gt;char sample[100][100][100], that is 1,000,000 bytes. Programming on a PC is OK but not for PIC.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Therein is a brief explanation on 3D arrays. If you do not understand, do not hesitate to leave comments us. Hope you have all understood the use of arrays. Next, I will explain a different kind of array in the next topic. &lt;/p&gt;&lt;span style=";font-family:arial;font-size:12;"  &gt;  &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-1303037020280788264?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/1303037020280788264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=1303037020280788264' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1303037020280788264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1303037020280788264'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/05/multidimensional-arrays.html' title='Multidimensional Arrays'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_ZoRUv8L3D60/SCWF_M8KdMI/AAAAAAAAAPc/wIavw1Qcs60/s72-c/2D+array7x3.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6921308074344081482</id><published>2008-05-05T19:46:00.000-07:00</published><updated>2008-05-05T20:30:57.202-07:00</updated><title type='text'>ADC scaling explained...</title><content type='html'>There seems to be some confusion regarding ADC scaling requirement so here are some examples why and how you would do it...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example No 1:  Voltage to be measured is higher than 5V...&lt;/span&gt;&lt;br /&gt;Do take note that PIC ADC has a maximum input of VDD (+5V) thus if you want to measure voltage higher than 5V, you need to do some scaling of the actual voltage before it gets into PIC.  Easiest way is to use a voltage divider using resistors (&lt;span style="font-style: italic;"&gt;for more demanding applications, an opamp-based circuit may be required&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;Lets look at an example.  Assuming you want to measure the automotive battery voltage.  Typically, the battery voltage will be between 11V (&lt;span style="font-style: italic;"&gt;standby&lt;/span&gt;) and 14V (&lt;span style="font-style: italic;"&gt;charging&lt;/span&gt;).  For safety reason, let's assume we design for 20V maximum input voltage (&lt;span style="font-style: italic;"&gt;25% safety factor&lt;/span&gt;).  To accomplish this, we'll use 4 resistors of 4.7k each...  a potentiometer can also be used to set it correctly.  Wire the resistors as shown below:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/SB_KJOlTNII/AAAAAAAAAac/H-I3hRq4Dtc/s1600-h/Voltage+Divider.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/SB_KJOlTNII/AAAAAAAAAac/H-I3hRq4Dtc/s400/Voltage+Divider.gif" alt="" id="BLOGGER_PHOTO_ID_5197094754891019394" border="0" /&gt;&lt;/a&gt;In the above circuit, when a 20V voltage is present at the input, input to the ADC will be 5V...  a 10V input will result in 2.5V input at the ADC...  thus, the input voltage has been scaled by factor of 1/4.  The ratio is obtained from the voltage divider...  &lt;span style="font-style: italic;"&gt;check some references if you not sure why this is so...&lt;/span&gt; :-)&lt;br /&gt;Voltage at PIC ADC Input = Actual Input x (R1 / (R1+R2+R3+R4))&lt;br /&gt;&lt;br /&gt;Assuming you use VDD (5V) as the ADC+ reference, the ADC reading will be 1023 when the ADC input is 5V (&lt;span style="font-style: italic;"&gt;actual input of 20V&lt;/span&gt;).  So, to get the actual voltage reading, you need to calculate it as follows:&lt;br /&gt;&lt;br /&gt;Actual Voltage = ADC Reading * Designed Maximum Voltage /1024.  Putting the actual numbers in, Actual Voltage = 1023 * 20 /1024 = 19.98V.  The small difference is because the 10-bit ADC maximum value is 1023 instead of 1024...&lt;br /&gt;&lt;br /&gt;Under this scenario, the maximum resolution is 20V/1024 = 19.5mV.&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'll post another example for expanded ADC resolution later...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6921308074344081482?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6921308074344081482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6921308074344081482' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6921308074344081482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6921308074344081482'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/05/adc-scaling-explained.html' title='ADC scaling explained...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/SB_KJOlTNII/AAAAAAAAAac/H-I3hRq4Dtc/s72-c/Voltage+Divider.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3409643783206077149</id><published>2008-04-28T19:13:00.000-07:00</published><updated>2008-05-02T11:45:15.755-07:00</updated><title type='text'>Arrays</title><content type='html'>&lt;b style=""&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt;    &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;Single Dimensional (1D).&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;Key in the code below. I know it is long…But there is a point to this. This is to show you how to eliminate redundant code. After keying in the code and compiling it and correcting your typing errors; burn it to your PIC. Connect a common cathode (or common anode) 7 segment LED to portB. When the PIC is powered up, you will see the number 0, 1, ..9 displayed in a endless loop.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border: medium none ; margin-left: 28.05pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1.5pt double windowtext; padding: 0in 5.4pt; width: 119.4pt;" valign="top" width="159"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;    &lt;v:stroke joinstyle="miter"&gt;    &lt;v:formulas&gt;     &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;     &lt;v:f eqn="sum @0 1 0"&gt;     &lt;v:f eqn="sum 0 0 @1"&gt;     &lt;v:f eqn="prod @2 1 2"&gt;     &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;     &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @0 0 1"&gt;     &lt;v:f eqn="prod @6 1 2"&gt;     &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;     &lt;v:f eqn="sum @8 21600 0"&gt;     &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;     &lt;v:f eqn="sum @10 21600 0"&gt;    &lt;/v:formulas&gt;    &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;    &lt;o:lock ext="edit" aspectratio="t"&gt;   &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:108pt;"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" title="L4v1P1"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 152px; height: 118px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P1.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1.5pt 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 120pt;" valign="top" width="160"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1026" type="#_x0000_t75" style="'width:108.75pt;height:84.75pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image003.jpg" title="L4v1P2"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 155px; height: 120px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P2.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1.5pt 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 120pt;" valign="top" width="160"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1027" type="#_x0000_t75" style="'width:108.75pt;height:84.75pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image005.jpg" title="L4v1P3"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P31.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 150px; height: 118px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v1P31.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1.5pt 1.5pt; padding: 0in 5.4pt; width: 119.4pt;" valign="top" width="159"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4 Ver 1 Page 1&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 120pt;" valign="top" width="160"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4 Ver 1 Page 2&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 120pt;" valign="top" width="160"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4v1 compiled&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Actually this is an example of bad programming. The code is large, it’s time consuming and the chances of making typos is high. I will now demonstrate arrays. This is how to define arrays:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char name[30]; &lt;span style=""&gt;            &lt;/span&gt;//This is an array of 30 characters.&lt;/p&gt;&lt;p class="MsoNormal"&gt;double tempC[10]; // Array of 10 floating point numbers&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;      &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;int x[5]; &lt;span style=""&gt;                       &lt;/span&gt;// An array of 5 elements that can hold 5 signed int.&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-weight: bold;"&gt;It like defining 5 variables.&lt;/span&gt;&lt;br /&gt;x[0] can store a value x[1] can store another and so on.&lt;br /&gt;x is a variable or const, and [0] is the location where the value is stored.&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Also important to note:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;      &lt;p class="MsoNormal"&gt;the &lt;span style="font-weight: bold;"&gt;[]&lt;/span&gt; in arrays do not mean optional, as it usually does in documentation standard.&lt;br /&gt;the first element of array is always 0.&lt;br /&gt;arrays can be of any valid C data type, ie, float, double, int or char.  &lt;!--[if !supportLineBreakNewLine]--&gt;  &lt;!--[endif]--&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;If you want to load the array with known values, do this when you declare you array:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;char base2[6] = {1, 2, 4, 8, 16, 32};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This array holds 6 elements, base2[0] is 1, base2[1] is 2, etc. etc. etc..&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Or you can do this:-&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;unsigned int base2[]={1,2,4,8,16,32,64,128,256,512,1024};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When you don’t specify number of elements, and when you compile the, compiler will count then number of element and assign 0 to the first element, 1 to the next one and so on. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Following me so far….Excellent!&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Firstly let’s use a variable cc7s as an array of chars. I set is as constant because the values will not change.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The point to this is that the code can be modified using arrays. Using the same code (new project, copy and paste), then change with the modifications in listing below.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="width: 246.2pt; margin-left: 88.2pt;" border="1" cellpadding="0" cellspacing="3" width="328"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 125.15pt;" valign="top" width="167"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1029" type="#_x0000_t75" style="'width:121.5pt;height:95.25pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image007.jpg" title="L4v2P1"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v2P11.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 192px; height: 150px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v2P11.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 115.05pt;" valign="top" width="153"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1030" type="#_x0000_t75" style="'width:125.25pt;height:97.5pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image009.jpg" title="L4v2P2"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v2P21.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 191px; height: 148px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v2P21.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 125.15pt;" valign="top" width="167"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4 Ver 2 Page 1&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt; width: 115.05pt;" valign="top" width="153"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4v2 compiled &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;OK, All i have done is replaced the variables with arrays and &lt;span style="font-weight: bold;"&gt;if()&lt;/span&gt; with &lt;span style="font-weight: bold;"&gt;case&lt;/span&gt;. Some what smaller code. But wait! I see a pattern! when &lt;span style="font-weight: bold;"&gt;count==0, cc7s[0] &lt;/span&gt;is displayed, when &lt;span style="font-weight: bold;"&gt;count==1, cc7s[1]&lt;/span&gt; is displayed and so on. Then it loops back and starts over. So, lets redo the Version 1 and 2 code. Type in the listing below.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Note: &lt;span style="font-weight: bold;"&gt;switch..case&lt;/span&gt; will be explained in a later chapter..&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border-style: outset inset inset outset; border-color: -moz-use-text-color; border-width: 1pt; margin-left: 136.95pt;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 144.15pt;" valign="top" width="192"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1031" type="#_x0000_t75" style="'width:132pt;height:99pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image011.jpg" title="L4v3P1"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v3P1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 198px; height: 148px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/L4v3P1.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 144.15pt;" valign="top" width="192"&gt;   &lt;p class="MsoNormal"&gt;Lesson 4 Ver 3 compiled&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;And that my dear students, is how you use arrays. It compiled to 83 bytes, as compared to 395 bytes in version 1. That’s almost 5 times smaller.&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border-style: outset inset inset outset; border-color: -moz-use-text-color; border-width: 1pt; margin-left: 44.75pt; width: 378px; height: 182px;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 264.3pt;" valign="top" width="352"&gt;   &lt;p class="MsoNormal"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1028" type="#_x0000_t75" style="'width:252pt;height:127.5pt'"&gt;    &lt;v:imagedata src="file:///C:\DOCUME~1\furry\LOCALS~1\Temp\msohtml1\01\clip_image013.jpg" title="1D%20array"&gt;   &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/1Darray.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://i300.photobucket.com/albums/nn36/9w2gu/Blog/PIC/1Darray.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;!--[endif]--&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;&lt;o:p&gt;&lt;span style="text-decoration: none;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let’s see if you understood the above lesson.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;&lt;o:p&gt;&lt;span style="text-decoration: none;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;u&gt;Skill Check!&lt;o:p&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;1. Declare an array called DOW and initialize it’s elements with first 3 characters of day of week beginning with Monday.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;2. What would need to do:-&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;a) To &lt;span style="font-weight: bold;"&gt;display&lt;/span&gt; decimal point with ALL the numbers.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;b) To &lt;span style="font-weight: bold;"&gt;display&lt;/span&gt; decimal point ONLY with odd numbers.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;c) To &lt;span style="font-weight: bold;"&gt;display&lt;/span&gt; decimal point ONLY with even number.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;span style="font-weight: bold;"&gt;Only display decimal point, not to blink it.&lt;/span&gt; &lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;Hint: You’ll need to refer to previous lessons.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;3. Write a program to display number from 0 to 9 in an endless loop. Turn on the decimal point for 150ms and then off it for 150ms for every number.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;4. Without changing the values of the arrays in the version 3 program, modify the program to display the numbers from 0 to 9 on a common anode 7 segment LED. (If you are already using a common anode, then do for common cathode).&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Hint: Common cathode is opposite of common anode.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3409643783206077149?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3409643783206077149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3409643783206077149' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3409643783206077149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3409643783206077149'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/arrays.html' title='Arrays'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-5457234925686667654</id><published>2008-04-23T23:29:00.000-07:00</published><updated>2008-04-25T00:37:24.986-07:00</updated><title type='text'>Let's C... Some ADC... 4U2C...</title><content type='html'>&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Updated:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After some of you got a little sober after the smooth operator 60s' twists, here's an an example of ADC usage in MikroC.&lt;br /&gt;&lt;br /&gt;The codes are commented so you should roughly knows what the codes is all about and what each line is doing.  I'll do a write up on ADC on the next post.  In most cases, some form of scaling is required so some understanding of ADC reference voltage is crucial.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_tMtO23Q5vm4/SBApHulTMxI/AAAAAAAAAXk/hRaQRopDzY4/s1600-h/L003a.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_tMtO23Q5vm4/SBApHulTMxI/AAAAAAAAAXk/hRaQRopDzY4/s400/L003a.gif" alt="" id="BLOGGER_PHOTO_ID_5192695583098483474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;How the board is wired up for the lesson... noticed the purposed-built LCD ribbon cable?&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/SBApIOlTMyI/AAAAAAAAAXs/4YwJDW4yX6s/s1600-h/DSC00123.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/SBApIOlTMyI/AAAAAAAAAXs/4YwJDW4yX6s/s400/DSC00123.jpg" alt="" id="BLOGGER_PHOTO_ID_5192695591688418082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Update 080425:  &lt;/span&gt;&lt;span style="font-style: italic;"&gt;A short brief on ADC.&lt;br /&gt;PIC18F4550 (and most ADC capable PIC) has a 10-bit ADC core.  The ADC is based on analog reading between VRef- to VRef+.  When input is at VRef-, the value returned will be 0 (zero) and when input is at VRef+, the value returned will be 1023 (2^10 - 1, i.e., 2 to the power of 10 minus 1). &lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/SBGF9-lTMzI/AAAAAAAAAX0/JMz--0fDtoI/s1600-h/L003b.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/SBGF9-lTMzI/AAAAAAAAAX0/JMz--0fDtoI/s400/L003b.gif" alt="" id="BLOGGER_PHOTO_ID_5193079145152852786" border="0" /&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;In the current example, via setting done with ADCON1, VRef- is set to VSS (GND) and VRef+ is set to VDD (+5V).   Under this environment, the resolution of the ADC is +5V/1024 = about 5mV.  When the potentiometer is at minimum (0V) the result is 0 and when at maximum (+5V) the result is 1023.  To get the actual voltage reading, you need to do scaling, the math as follows:&lt;br /&gt;Actual Voltage = (ADC Reading * Value at VRef+) / 1024&lt;br /&gt;i.e., if result is 512, then the actual voltage is 512 * 5 / 1024 = 2.5V&lt;br /&gt;&lt;br /&gt;If you need higher resolution, you can provide the PIC with your own VRef- &amp;amp; VRef+ directly to the AN2 &amp;amp; AN3 pins.  Change ADCON1 settings to 0b00111011.  If you set VRef+ to about 1V, the resolution becomes 1mV (1V/1024).&lt;br /&gt;&lt;br /&gt;For quick reference, ADCON1 setting information is below:&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/SBGH0OlTM0I/AAAAAAAAAX8/Vyy4X19-qE4/s1600-h/L003c.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/SBGH0OlTM0I/AAAAAAAAAX8/Vyy4X19-qE4/s400/L003c.gif" alt="" id="BLOGGER_PHOTO_ID_5193081176672383810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;On PIC18F4550, the analog pins are on 3 separate ports...  do your own searching below...  Remember to set TRISA, TRISB, TRISE and ADCON1 configuration accordingly...&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/SBGKCulTM1I/AAAAAAAAAYE/Q1E8wMHkCXU/s1600-h/L003d.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/SBGKCulTM1I/AAAAAAAAAYE/Q1E8wMHkCXU/s400/L003d.gif" alt="" id="BLOGGER_PHOTO_ID_5193083624803742546" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-5457234925686667654?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/5457234925686667654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=5457234925686667654' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5457234925686667654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5457234925686667654'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lets-c-some-adc-4u2c.html' title='Let&apos;s C... Some ADC... 4U2C...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_tMtO23Q5vm4/SBApHulTMxI/AAAAAAAAAXk/hRaQRopDzY4/s72-c/L003a.gif' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4022209954312520707</id><published>2008-04-23T07:20:00.000-07:00</published><updated>2008-04-24T07:19:04.106-07:00</updated><title type='text'>Smooth Operators</title><content type='html'>&lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;Relational operators.&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Relational operators are used indecision making. There are 6 different type of operator at your disposal. They are:-&lt;/p&gt;  &lt;table class="MsoNormalTable" style="margin-left: 30pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 4.5pt double windowtext; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;Op&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 4.5pt 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;Comment&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;==   &lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;is   equal to&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;!=&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;not   equal to&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;less   than&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;=&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;less   than OR equals to&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;more   than&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 33.35pt;" valign="top" width="44"&gt;   &lt;p class="MsoNormal" style=""&gt;&gt;=&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 130.8pt;" valign="top" width="174"&gt;   &lt;p class="MsoNormal" style=""&gt;more   than OR equals to&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;These operators are used in loops, if(), while, for() or where ever is decision needs to be made. Take care when using this. Example if you want the loop to perform 4 cycles, writing a for loop for example:&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;/p&gt;&lt;blockquote&gt;for (x=1; x&lt;4; x =4;x++); This only preform 3 iterations (loops), because when x=4, the condition will be false. 4&lt;4, No 4 is equal to 4. So to overcome this problem, use x&lt;=4 or x&lt;5. This will achieve the result you want of 4 loops&lt;/blockquote&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;Bit operators&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="border-collapse: collapse; margin-left: 6.75pt; margin-right: 6.75pt;" align="left" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 4.5pt double windowtext; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;&amp;amp;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 4.5pt 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;AND&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;|&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;OR&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;~&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;NOT&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;^&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;XOR&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;&gt;&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;Shift right&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 48.15pt;" valign="top" width="64"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;&lt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 65.85pt;" valign="top" width="88"&gt;   &lt;p class="MsoNormal" style=""&gt;Shift left&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;How this works is as follows, variables alpha, bravo and result used.&lt;/p&gt;      &lt;p class="MsoNormal" style=""&gt;alpha=0b10101010&lt;br /&gt;bravo=0b11000110&lt;br /&gt;result=0;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;AND&lt;/span&gt;&lt;br /&gt;result=alpha &amp;amp; bravo; &lt;/p&gt;      &lt;p class="MsoNormal" style=""&gt;10101010   alpha&lt;br /&gt;11000110   bravo&lt;br /&gt;-------------&lt;br /&gt;10000010  result&lt;br /&gt;========&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Only when BOTH values are 1 is the result 1. Similar to multiplication.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;OR&lt;/span&gt;&lt;br /&gt;result = alpha | bravo; &lt;/p&gt;      &lt;p class="MsoNormal" style=""&gt;10101010  alpha&lt;br /&gt;11000110  bravo&lt;br /&gt;------------&lt;br /&gt;11101110  result&lt;br /&gt;=======&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;When EITHER values is 1, is the result 1. Similar to addition.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;NOT&lt;/span&gt;&lt;br /&gt;result= ~alpha; &lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;10101010  alpha&lt;br /&gt;------------&lt;br /&gt;01010101  result&lt;br /&gt;=======&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;When bit is 1 then result 0, when bit is 0 result 1.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;XOR (exclusive OR)&lt;/span&gt;&lt;br /&gt;result=alpha ^ bravo; &lt;/p&gt;      &lt;p class="MsoNormal" style=""&gt;10101010   alpha&lt;br /&gt;11000110   bravo&lt;br /&gt;------------&lt;br /&gt;01101100   result&lt;br /&gt;========&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;When BOTH values 1 OR, BOTH values 0, result 0. When either value 1 AND 0, result 1.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;Shift right&lt;/span&gt;&lt;br /&gt;result=alpha &gt;&gt; 2; &lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;10101010   alpha&lt;br /&gt;------------&lt;br /&gt;00101010   result&lt;br /&gt;========&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Moves 2 bits to right and replaces left most bits with 0.&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;Shift left.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt;result=alpha &lt;&lt; 3 &lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;10101010   alpha&lt;br /&gt;-----------&lt;br /&gt;01010000   result&lt;br /&gt;=======&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Moves 3 bits to left and replaces right most bits with 0.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="font-weight: bold;"&gt;Boolean operators.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;There will come a time, you will need to check on more and one value to make a decision. In your program you could do this:-&lt;/p&gt;              &lt;p class="MsoNormal" style=""&gt;if (portb.f4==1) {&lt;br /&gt;if (portc.f2==1) {&lt;br /&gt;.&lt;br /&gt;do processing.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;}&lt;br /&gt;}&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;This code will check if portb.f4=1 then check if portc.f2 = 1 then process the lines below it.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Another way of doing this will be by using a Boolean operator.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if (portb.4==1 &amp;amp;&amp;amp; portc.f2 ==1) {&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;do processing1;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;}&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;else {&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;do processing2;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;}&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;The &amp;amp;&amp;amp; is a Boolean AND&lt;/p&gt;  &lt;table class="MsoNormalTable" style="border-collapse: collapse; margin-left: 6.75pt; margin-right: 6.75pt;" align="left" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style="height: 14.6pt;"&gt;   &lt;td style="border: 4.5pt double windowtext; padding: 0in 5.4pt; width: 23.7pt; height: 14.6pt;" valign="top" width="32"&gt;   &lt;p class="MsoNormal" style=""&gt;||&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 4.5pt 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 29.55pt; height: 14.6pt;" valign="top" width="39"&gt;   &lt;p class="MsoNormal" style=""&gt;OR&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: double double double none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 4.5pt 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 3in; height: 14.6pt;" valign="top" width="288"&gt;   &lt;p class="MsoNormal" style=""&gt;TRUE when EITHER condition is true&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style="height: 13.85pt;"&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 23.7pt; height: 13.85pt;" valign="top" width="32"&gt;   &lt;p class="MsoNormal" style=""&gt;&amp;amp;&amp;amp;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 29.55pt; height: 13.85pt;" valign="top" width="39"&gt;   &lt;p class="MsoNormal" style=""&gt;AND&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 3in; height: 13.85pt;" valign="top" width="288"&gt;   &lt;p class="MsoNormal" style=""&gt;TRUE when BOTH/ALL condition true&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style="height: 13.85pt;"&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 4.5pt 4.5pt; padding: 0in 5.4pt; width: 23.7pt; height: 13.85pt;" valign="top" width="32"&gt;   &lt;p class="MsoNormal" style=""&gt;!&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 29.55pt; height: 13.85pt;" valign="top" width="39"&gt;   &lt;p class="MsoNormal" style=""&gt;NOT&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 4.5pt 4.5pt medium; padding: 0in 5.4pt; width: 3in; height: 13.85pt;" valign="top" width="288"&gt;   &lt;p class="MsoNormal" style=""&gt;TRUE when FALSE&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;There are 3 Boolean operators, they are:&lt;/p&gt;  &lt;p class="MsoNormal" style="font-weight: bold;"&gt;Using OR&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if(var1==3 || var2 ==4 || varN==”CLS”) {&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;If either condition is true, process code below the if.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="font-weight: bold;"&gt;Using AND&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if(var1==3 &amp;amp;&amp;amp; var2==4 &amp;amp;&amp;amp; varN==”CLS”) {&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Only when all condition are true, process code below the if.&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-weight: bold;"&gt;Using NOT&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if (!EOF) {&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if not end of file process code below if.&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;Assignment Operator&lt;/span&gt;  &lt;p class="MsoNormal" style=""&gt;The single equal sign (=) is an assignment operator and assigns a value to a variable or constant (aka lvalues) AND is not a and used for comparison. Common mistake.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Ex.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;if(portb==128) ….checks if portb is equal to 128&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;portb = 128; … assigns the value 128 to portb.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;name[] = “9w2gu”&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;error = 255&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;const int ms=50;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="font-weight: bold;"&gt;Math operators&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;We all know how to do math right? We all know what + - * / % means.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;But wait! What is * / %, not in my math book!&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;* is multiplication&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;/ is division&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;% modulus (remainder value)&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Now you want to perform calculation on 3 numbers. &lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;3 * 2 + 1;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Though not wrong (but not the answer you wanted), and answer will be 7, but the () should be used to group the calculation. (3 * 2) + 1 = 3 * 2 +1.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;If I type 1 * 2 + 3 the answer now will be 6. This is because multiplication has a higher precedence than addition. So if you wanted to add then multiply, &lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;then 3 * (2 + 1) = 9. If there are many ( ) within a formula, the inner most group of ( ) will be calculated first.&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;Ex. &lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;result=2*(24/x-(3*y))&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;(3*y) is calculated first then 24/x. Then the subtraction and last multiplied by 2.&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4022209954312520707?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4022209954312520707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4022209954312520707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4022209954312520707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4022209954312520707'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/smooth-operators.html' title='Smooth Operators'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-8244806451169747678</id><published>2008-04-21T17:58:00.000-07:00</published><updated>2008-04-21T18:11:39.468-07:00</updated><title type='text'>Quick Simulation on MikroC...</title><content type='html'>MikroC can do software simulation to check your codes...  I'll show the basic method below...&lt;br /&gt;&lt;br /&gt;To start with, make sure the debugger is set to "Software Simulator".  It's on the lower left hand side of the screen.  The other option is for MikroC custom-made ICD2 equivalent...  Unfortunately, MikroC does not support the ICD2 from Microchip...  their way of making extra buck by requiring you to buy their ICD2...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/SA04lOlTMsI/AAAAAAAAAW8/McAgnzjEoq8/s1600-h/D001.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/SA04lOlTMsI/AAAAAAAAAW8/McAgnzjEoq8/s400/D001.gif" alt="" id="BLOGGER_PHOTO_ID_5191868157648908994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Then, you start the Debugger by pressing F9 or use the menu or the icon...  Icon is on the right hand side...  the one with the green arrow pointing downward...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_tMtO23Q5vm4/SA04lelTMtI/AAAAAAAAAXE/nzGeL6dhbps/s1600-h/D002.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_tMtO23Q5vm4/SA04lelTMtI/AAAAAAAAAXE/nzGeL6dhbps/s400/D002.gif" alt="" id="BLOGGER_PHOTO_ID_5191868161943876306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Once the debugger started, a Watch window will open...  this is you view toward everything...  basically you select the variable you want to see, from the list, then click 'Add'...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_tMtO23Q5vm4/SA04lelTMuI/AAAAAAAAAXM/_qjBo-c6xCM/s1600-h/D003.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_tMtO23Q5vm4/SA04lelTMuI/AAAAAAAAAXM/_qjBo-c6xCM/s400/D003.gif" alt="" id="BLOGGER_PHOTO_ID_5191868161943876322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;After you click 'Add', the variable selected, in this case PORTB, will appear in the watch window.  Click on the '0' next to PORTB and a small icon will appear next to the '0'.  Click that icon to bring up the viewing option...  In this case, just select binary...  using binary, we can see how the bits look like...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/SA04lulTMvI/AAAAAAAAAXU/7StMWIbkJy0/s1600-h/D004.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/SA04lulTMvI/AAAAAAAAAXU/7StMWIbkJy0/s400/D004.gif" alt="" id="BLOGGER_PHOTO_ID_5191868166238843634" border="0" /&gt;&lt;/a&gt;After clicking OK, you're back to the watch window...  Press 'F8' to step through your code...  you'll see a blue bar highlighting the next instruction to be executed...  PORTB value will change accordingly...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/SA04mOlTMwI/AAAAAAAAAXc/s8m1cSnCJAk/s1600-h/D005.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/SA04mOlTMwI/AAAAAAAAAXc/s8m1cSnCJAk/s400/D005.gif" alt="" id="BLOGGER_PHOTO_ID_5191868174828778242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;That's it...  you've just simulated your code...  if it work in the simulator, it stands very good chance to work in the actual circuit...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-8244806451169747678?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/8244806451169747678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=8244806451169747678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8244806451169747678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8244806451169747678'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/quick-simulation-on-mikroc.html' title='Quick Simulation on MikroC...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_tMtO23Q5vm4/SA04lOlTMsI/AAAAAAAAAW8/McAgnzjEoq8/s72-c/D001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3995530205159079779</id><published>2008-04-20T20:21:00.000-07:00</published><updated>2008-04-20T20:32:22.155-07:00</updated><title type='text'>Exercise 1: My way...</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_tMtO23Q5vm4/SAwKkbZA4-I/AAAAAAAAAW0/k26K0_2hf9U/s1600-h/E001.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_tMtO23Q5vm4/SAwKkbZA4-I/AAAAAAAAAW0/k26K0_2hf9U/s400/E001.gif" alt="" id="BLOGGER_PHOTO_ID_5191536091395580898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Different approach... same result...  mainly to show that in programming, there is no right way or wrong way...  just either more compact (less codes space) or faster execution...  This code compile to 206 bytes only as opposed to over 1000 bytes on 9w2dtr version...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3995530205159079779?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3995530205159079779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3995530205159079779' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3995530205159079779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3995530205159079779'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/exercise-1-my-way.html' title='Exercise 1: My way...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_tMtO23Q5vm4/SAwKkbZA4-I/AAAAAAAAAW0/k26K0_2hf9U/s72-c/E001.gif' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-2733806363440245415</id><published>2008-04-20T20:02:00.000-07:00</published><updated>2008-04-20T20:06:35.916-07:00</updated><title type='text'>Assignment 1</title><content type='html'>Assignment 1 submission. I thought of using simple codes but no idea how.... :(&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jMzsrLusGK0/SAwEfwFDKNI/AAAAAAAAABE/DkJL198bunQ/s1600-h/Ex1.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_jMzsrLusGK0/SAwEfwFDKNI/AAAAAAAAABE/DkJL198bunQ/s320/Ex1.bmp" alt="" id="BLOGGER_PHOTO_ID_5191529413979875538" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-2733806363440245415?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/2733806363440245415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=2733806363440245415' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/2733806363440245415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/2733806363440245415'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/assignment-1.html' title='Assignment 1'/><author><name>9w2dtr</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_jMzsrLusGK0/SAwEfwFDKNI/AAAAAAAAABE/DkJL198bunQ/s72-c/Ex1.bmp' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6548375248977148427</id><published>2008-04-20T17:52:00.001-07:00</published><updated>2008-04-20T18:02:36.110-07:00</updated><title type='text'>Prepare for next lesson... Analog-to-Digital Coversion</title><content type='html'>Hi All,&lt;br /&gt;&lt;br /&gt;Thank you 9w2gu for the posts on C loops and exercises. &lt;br /&gt;&lt;br /&gt;I'll be introducing the analog-to-digital (ADC) function as next lesson.  It you want some real world view, you can get yourself the LM35 temperature sensor...  It's a temperature sensor with linear temperature output... a 3-pins device that look like a transistor in TO-92 casing...  We'll be using the LCD to show the temperature...  Later will introduce some simple thermostat functions to further dwell into C programming...&lt;br /&gt;&lt;br /&gt;If you do not fancy getting a temperature sensor, you can hook up the pots on the development board...  simulated rather than actual... :-)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Sensors/LM35.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Sensors/LM35.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In the spirit on recycling electrons, I will not explain LM35 in detail here.  A quick search on Google and &lt;a href="http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Sensors/TempLM35.html"&gt;this site&lt;/a&gt; came up and I believe it provide good description on the device.  Go check it out...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6548375248977148427?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6548375248977148427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6548375248977148427' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6548375248977148427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6548375248977148427'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/prepare-for-next-lesson-analog-to.html' title='Prepare for next lesson... Analog-to-Digital Coversion'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-5279688315361189296</id><published>2008-04-19T19:26:00.000-07:00</published><updated>2008-04-20T06:39:41.646-07:00</updated><title type='text'>Programming practice.</title><content type='html'>You should alaredy have some basic knowledge about C programming.&lt;br /&gt;&lt;br /&gt;Now:-&lt;br /&gt;1. Write a program to blink 8 LED connected to portb one after another. Before trun on the next led off the previous one.&lt;br /&gt;&lt;br /&gt;2. Do similar as above and this time when last LED is lit, blink in reverse...ie led 1 to 8 and 7 to 1 endlessly.&lt;br /&gt;&lt;br /&gt;3. Blink 2 LED at a time for all 8 LED. 1,2, then 3,4...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Post you code here. If you have errors or have problems let us know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-5279688315361189296?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/5279688315361189296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=5279688315361189296' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5279688315361189296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5279688315361189296'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/programming-practice.html' title='Programming practice.'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-7865946286098291378</id><published>2008-04-19T06:39:00.000-07:00</published><updated>2008-04-19T19:26:24.438-07:00</updated><title type='text'>Prefix and Postfix</title><content type='html'>&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;Basir has already given a brief explanation of prefix and postfix. I will show some examples.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse; width: 458px; height: 98px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1.5pt double windowtext; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Prefix&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none double; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1.5pt; padding: 0in;" width="296"&gt;&lt;p class="MsoNormal"&gt; &lt;/p&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td color="-moz-use-text-color windowtext windowtext" style="border-style: none double double; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;count = ++tick;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 222.1pt;" valign="top" width="296"&gt;   &lt;p class="MsoNormal"&gt;increase variable tick by 1, then copies the value of tick   to count &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1.5pt 1.5pt; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;count = --tick;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 222.1pt;" valign="top" width="296"&gt;   &lt;p class="MsoNormal"&gt;decrease variable tick by 1, then copies the value of tick   to count &lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse; width: 458px; height: 98px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1.5pt double windowtext; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Postfix&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none double; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1.5pt; padding: 0in;" width="296"&gt;&lt;p class="MsoNormal"&gt; &lt;/p&gt;&lt;br /&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1.5pt 1.5pt; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;count&lt;span style=""&gt;  &lt;/span&gt;= tick++; &lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 222.1pt;" valign="top" width="296"&gt;   &lt;p class="MsoNormal"&gt;copies the value of variable tick to count then increase   tick by 1&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none double double; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1.5pt 1.5pt; padding: 0in 5.4pt; width: 95.3pt;" valign="top" width="127"&gt;   &lt;p class="MsoNormal"&gt;count = tick--;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none double double none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1.5pt 1.5pt medium; padding: 0in 5.4pt; width: 222.1pt;" valign="top" width="296"&gt;   &lt;p class="MsoNormal"&gt;copies the value of variable tick to count then decrease   tick by 1&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;int count =0, tick =0;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;        &lt;p class="MsoNormal"&gt;count= ++tick;&lt;span style=""&gt;              &lt;/span&gt;        //tick = 1 count = 1&lt;br /&gt;count= --tick;&lt;span style=""&gt;               &lt;/span&gt;        //tick = 0 count = 0&lt;br /&gt;count= tick++;&lt;span style=""&gt;              &lt;/span&gt;        //tick = 1 count = 0&lt;br /&gt;count= tick--;&lt;span style=""&gt;               &lt;/span&gt;        //tick = 0 count = 1&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You can also do the following;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;      &lt;p class="MsoNormal"&gt;count += total;&lt;span style=""&gt;              &lt;/span&gt;        //is same as count=count + total;&lt;br /&gt;count -= total;&lt;span style=""&gt;               &lt;/span&gt;       // is count=count – total;&lt;br /&gt;count *=3;&lt;span style=""&gt;                    &lt;/span&gt;              //  is count=count * 3;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Confused? Anyone doesn’t understand, keep your hand on your mouse and post comments. :)&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-7865946286098291378?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/7865946286098291378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=7865946286098291378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7865946286098291378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7865946286098291378'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/prefix-and-postfix.html' title='Prefix and Postfix'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6895468409926831781</id><published>2008-04-18T09:52:00.000-07:00</published><updated>2008-04-19T06:26:40.172-07:00</updated><title type='text'>Loop de loop.</title><content type='html'>In C there are 3 type of loops. The function of a loop is to repeatedly execute a set of instructions within that loop until some condition is met or indefinitely.&lt;br /&gt;&lt;br /&gt;The type of loops are:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;While&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Do..while&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;For&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A loop will always execute instructions as long as the expression is true. True in C is any non zero value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;WHILE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;while (expression){ statement }&lt;br /&gt;&lt;br /&gt;Portb=0b10101010;&lt;br /&gt;while(1) {&lt;br /&gt;Portb = ~portb;&lt;br /&gt;Delay_ms(400);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;In the code above, the loop will never end. The code between {…} is executed endlessly. This is usually used for main loops of  programs the don’t end.&lt;br /&gt;&lt;br /&gt;.&lt;br /&gt;while(Portb.f1 == 0) {&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This loop will repeat until the state of portb.f1 changes. Meaning when portb.f1  = 1 the loop exits.&lt;br /&gt;&lt;br /&gt;Important point to notice is that the expression is evaluated before the code between {…} is executed. If expression is false then the entire code between {…} is skipped. If you want to execute the code at least once, then you need to use a do…while loop.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;do…while&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;do { statement } while (expression);&lt;br /&gt;&lt;br /&gt;As mentioned above, the do while(as it is called) executes code between {…} at least once before deciding on continuing with the loop or not.&lt;br /&gt;&lt;br /&gt;do {&lt;br /&gt;CountUp++;&lt;br /&gt;CountDn--;&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;} while(Portb.f4==1) ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;for()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;for ([init-expression]; [condition-expression]; [increment-expression]) statement&lt;br /&gt;note: square brackets indicate optional.&lt;br /&gt;&lt;br /&gt;The for loop can be used like do or while loop, but I strongly recommend against it.&lt;br /&gt;&lt;br /&gt;for( ; ;) {&lt;br /&gt;CountUp++&lt;br /&gt;CountDd—&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This is an &lt;span style="font-weight: bold;"&gt;endless loop&lt;/span&gt;. There are only two way to exit this loop (or any endless loop).&lt;br /&gt;That is using the break statement or branch out of  the loop using the goto command. &lt;span style="color: rgb(255, 0, 0);"&gt;I personally, strongly discouraged the use of goto. Programming becomes unstructured and difficult to debug.&lt;/span&gt; Alright, back to the for loop.&lt;br /&gt;&lt;br /&gt;init-expression it the initial value of the variable you want to start with.&lt;br /&gt;&lt;br /&gt;condition-expression the loop must satisfy this condition to exit.&lt;br /&gt;&lt;br /&gt;increment-expression here you increased or decrease your variable.&lt;br /&gt;&lt;br /&gt;signed int CountUp =0, CountDn=0;&lt;br /&gt;for(count=1; count &lt;=3; count++) { &lt;br /&gt;    ++CountUp; &lt;br /&gt;    --CountDn;&lt;br /&gt;}   &lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;  &lt;table class="MsoTableGrid" style="border: 1pt inset ;" border="1" cellpadding="0" cellspacing="3"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 88.8pt;" valign="top" width="118"&gt;   &lt;p class="MsoNormal"&gt;When Count is&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" valign="top" width="81"&gt;   &lt;p class="MsoNormal"&gt;CountUp&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" valign="top" width="81"&gt;   &lt;p class="MsoNormal"&gt;CountDn&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 88.8pt;" width="118"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;-1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 88.8pt;" width="118"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;-2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 88.8pt;" width="118"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;-3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 88.8pt;" width="118"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt outset ; padding: 0in 5.4pt; width: 60.85pt;" width="81"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Before the loop begins it sets to to 1.&lt;br /&gt;Then checks if count is equal to 3.&lt;br /&gt;Increases the variable count by 1.&lt;br /&gt;&lt;br /&gt;Since count is not equal to 3 it executes the code between { }, which increases CountUp and decreases CountDn.&lt;br /&gt;&lt;br /&gt;When count is 4, the loop exits.&lt;br /&gt;&lt;br /&gt;The for() can be use in other ways. But this is the most basic you will need to you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6895468409926831781?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6895468409926831781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6895468409926831781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6895468409926831781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6895468409926831781'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/loop-de-loop.html' title='Loop de loop.'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3884192421297571308</id><published>2008-04-17T18:23:00.001-07:00</published><updated>2008-04-17T18:29:04.938-07:00</updated><title type='text'>Where Do We Want to Go From Here...</title><content type='html'>Hello gang,&lt;br /&gt;&lt;br /&gt;The last two lessons should get you started with PIC...  By now, you would have known how to code, compile and program the PIC.  You would have been able to blink LED, read some switches, make some sound, display text on the LCD and so on...&lt;br /&gt;&lt;br /&gt;Now, with the &lt;span style="color: rgb(255, 0, 0); font-weight: bold; font-style: italic;"&gt;introductory lessons done&lt;/span&gt;, I need to know what you all &lt;span style="color: rgb(255, 0, 0); font-weight: bold; font-style: italic;"&gt;want to do next&lt;/span&gt;...  may be pick a project and do it interactively here...  &lt;span style="color: rgb(255, 0, 0); font-style: italic; font-weight: bold;"&gt;Give your feedback&lt;/span&gt; and we'll take it from there...&lt;br /&gt;&lt;br /&gt;9W2DTR, may be you want to start on your temperature sensor project for your spindle?&lt;br /&gt;Or I could do the rear blinker project for 9W2ALT,...&lt;br /&gt;The rest of you... say your piece... including the &lt;span style="color: rgb(204, 0, 0); font-weight: bold; font-style: italic;"&gt;foreign visitors to this site&lt;/span&gt; :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3884192421297571308?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3884192421297571308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3884192421297571308' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3884192421297571308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3884192421297571308'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/where-do-we-want-to-go-from-here.html' title='Where Do We Want to Go From Here...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-321710908617532247</id><published>2008-04-14T09:13:00.001-07:00</published><updated>2008-04-14T18:06:43.732-07:00</updated><title type='text'>Addition to variables</title><content type='html'>&lt;span style="color: rgb(0, 153, 0);"&gt;Thanks 9W2GU on the extra notes.  I have made some addition to your addition, as marked by the green text.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Some extra notes on variables.  Variables cannot &lt;span style="color: rgb(0, 102, 0);"&gt;start &lt;/span&gt;with numbers special characters.  Only with underscore "_" and characters.   Variables in C can be up to 32 characters long.  It is good practice to give your variables meaningful name.  Example, if you need a variable for voltage, define the variable as :-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;signed double Voltage;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Defining it as "x" for example, will work too, but later you may have problems debugging your code.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Case Sensitivity&lt;/span&gt; &lt;p&gt;mikroC identifiers are &lt;em&gt;not&lt;/em&gt; case sensitive at present, so that  &lt;code&gt;Sum&lt;/code&gt;, &lt;code&gt;sum&lt;/code&gt;, and &lt;code&gt;suM&lt;/code&gt; represent an equivalent  identifier.  However, future versions of mikroC will offer the option of  activating/suspending case sensitivity.  The only exceptions at present are the  reserved words &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;interrupt&lt;/code&gt; which must be  written in lowercase.&lt;/p&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;TRISA=0b00110011; is the same as TrisA=&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;0b00110011;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;portb=128;&lt;br /&gt;PortB=128;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Variables as explained by Basir hold values that may and usually changes. Another type of variable type is a constant, where it's value does not change or rarely changes.  &lt;span style="color: rgb(0, 153, 0);"&gt;A constant is not a variable, it cannot change it's value.  If you try to assign or change it's value apart elsewhere in your program, MikroC will give you an error.  Variables use RAM space whereas Constants use ROM.  Take note that MikroC is an optimizing compiler, i.e., it will remove redundant codes, variables and constants whenever possible.  Make it a practice to use constants instead of hard-coded numbers.  It will helps in two ways... it prevent unintentionally changing the value of a constant and if the constant is used in several places, you only need to change once at the declaration line.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;const double PI = 3.1415;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;const byte HTab = 0x09;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;HTab is now set to horizantal tab. And can be used like:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Lcd_Out(HTab+"Hello, World");&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Will output a tab and Hello, World on your LCD.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-321710908617532247?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/321710908617532247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=321710908617532247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/321710908617532247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/321710908617532247'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/addation-to-variables.html' title='Addition to variables'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3216089768736373366</id><published>2008-04-14T01:17:00.000-07:00</published><updated>2008-04-14T02:08:42.749-07:00</updated><title type='text'>Lesson 2:  Learning Points...</title><content type='html'>The &lt;a href="http://microchippiclessons.blogspot.com/2008/04/lesson-2-lets-c-some-more-lcd-now.html"&gt;Lesson 2: Let's C some more... LCD now active&lt;/a&gt; introduce several key learning points and I'll cover them individually.  They are:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Variables&lt;/span&gt;&lt;br /&gt;Variables are placeholders, kinda like scratch pad, i.e., a place for you to keep temporary information, intermediate values and so on.  Variable must be of a data type (&lt;span style="font-style: italic;"&gt;already explained by 9W2GU below&lt;/span&gt;).  Variable name can be anything as long as it is not the same as those already defined by C (&lt;span style="font-style: italic;"&gt;such as integer, for, while, if, etc&lt;/span&gt;) and must start with an alphabet.&lt;br /&gt;&lt;br /&gt;In the example, four (4) variables were used (&lt;span style="font-style: italic;"&gt;bCount, iCount, BoutText, ioutText&lt;/span&gt;).  In C, &lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;ALL variables must be defined before use&lt;/span&gt;, otherwise the compiler will give you error(s).  If you refer to the codes:&lt;br /&gt;&lt;br /&gt;bCount defined as unsigned char (&lt;span style="font-style: italic;"&gt;thus maximum value is 255&lt;/span&gt;).&lt;br /&gt;iCount defined as unsigned integer (&lt;span style="font-style: italic;"&gt;thus maximum value is 65535&lt;/span&gt;).&lt;br /&gt;BoutText[4]/IoutText[7] are defined as unsigned character array.  Note that array uses [] square bracket.  In C, array size is one less than defined, thus BoutText can hold 3 characters only.  In this example, it will be used to store ASCII characters for the LCD functions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Using LCD&lt;/span&gt;&lt;br /&gt;The functions related to LCD are explained in detailed in the help file and manual.  Before using the LCD, it must be initialized (&lt;span style="font-style: italic;"&gt;reseting the LCD&lt;/span&gt;).  This is done using the LCD_Init() function.  This function assumes that the wiring is done as per the schematic given in the help file.  In our case, we use PortD for the connections thus the function is LCD_Init(&amp;amp;PORTD).  There is another function call LCD_Config() provided by MikroC.  Use this function IF you wiring is not as per the schematic in the help file.&lt;br /&gt;&lt;br /&gt;LCD_Cmd() sends specific command to the LCD such as clearing the screen, turning off the cursor and so on.&lt;br /&gt;&lt;br /&gt;It must be noted that the &lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;LCD functions that display text only accept ASCII&lt;/span&gt; characters, i.e., it will not automatically convert a number into a meaningful display.  This is what and why we have line 29 &amp;amp; 31.  Line 29 convert an integer into the ASCII equivalent while Line 31 convert a byte into the ASCII equivalent.  IntToStr and ByteToStr are built-in functions.  Look up the help file and you'll see why I've made the BoutText and ioutText variable definitions.&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;More C Syntax&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;Line 23, 27, 33 introduce a C notations.&lt;br /&gt;&lt;br /&gt;bCount++; means increment variable bCount by 1 thus is equivalent to the statement bCount=bCount+1;&lt;br /&gt;Similarly bCount--; means decrement variable bCount by 1 (&lt;span style="font-style: italic;"&gt;equivalent to bCount=bCount-1;&lt;/span&gt;).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3216089768736373366?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3216089768736373366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3216089768736373366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3216089768736373366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3216089768736373366'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lesson-2-learning-points.html' title='Lesson 2:  Learning Points...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3433529001063543148</id><published>2008-04-11T08:53:00.000-07:00</published><updated>2008-04-11T09:33:47.811-07:00</updated><title type='text'>Data types</title><content type='html'>In C, data can be defined in 3 types. They are int, char, double or float.&lt;br /&gt;&lt;br /&gt;int is integers, which is numbers with no decimal point.&lt;br /&gt;char hold a maximum value of 255. Usually used to store characters in arrays.&lt;br /&gt;float or double store values with decimal point.&lt;br /&gt;&lt;br /&gt;Now, these values data types can be positive or negative. Example:-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;unsigned int counter;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So now counter is a non negative integer value. If you want the variable counter to be able to store negative values, it would be defined as:-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;signed int counter;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is a limit to the value counter can hold.  Below is the table for your reference  of the maximum and minimum data type values.&lt;br /&gt;&lt;br /&gt; &lt;table class="MsoNormalTable" style="border: 1pt solid windowtext; width: 79.04%;" border="1" cellpadding="0" width="79%"&gt;  &lt;thead&gt;   &lt;tr style=""&gt;    &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;    &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;/td&gt;    &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;    &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Size in bytes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;/td&gt;    &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;    &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Range&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;    &lt;/td&gt;   &lt;/tr&gt;  &lt;/thead&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;(unsigned)   char&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;0 .. 255&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;signed   char&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;- 128 .. 127&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;(signed)   short (int)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;- 128 .. 127&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;unsigned   short (int)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;0 .. 255&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;(signed)   int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-32768 .. 32767&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;unsigned   (int)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;0 .. 65535&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;(signed)   long (int)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;-2147483648 .. 2147483647&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;unsigned   long (int)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;0 .. 4294967295&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;float&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;±1.17549435082 * 10-&lt;sup&gt;38&lt;/sup&gt; &lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;..   ±6.80564774407 * 10&lt;sup&gt;38&lt;/sup&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;double&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;±1.17549435082 * 10-&lt;sup&gt;38&lt;/sup&gt;   .. ±6.80564774407 * 10&lt;sup&gt;38&lt;/sup&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 27.64%;" valign="top" width="27%"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;long   double&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 20.34%;" width="20%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0.75pt; width: 50.24%;" width="50%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;±1.17549435082 * 10-&lt;sup&gt;38&lt;/sup&gt;   .. ±6.80564774407 * 10&lt;sup&gt;38&lt;/sup&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;br /&gt;&lt;br /&gt;So use the right data types and save memory. I will explain long and short in a later post.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3433529001063543148?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3433529001063543148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3433529001063543148' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3433529001063543148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3433529001063543148'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/data-types.html' title='Data types'/><author><name>9w2gu</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_ZoRUv8L3D60/SKb5c8TMzbI/AAAAAAAAAY4/s9tBB9B3JO8/S220/Icon48.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-7862018613522018541</id><published>2008-04-10T08:12:00.000-07:00</published><updated>2008-04-10T08:35:15.082-07:00</updated><title type='text'>Lesson 2  Part 2</title><content type='html'>If you have wired the LCD as per &lt;a href="http://microchippiclessons.blogspot.com/2008/04/preparation-for-next-lesson-wire-up-lcd.html"&gt;connection schematic&lt;/a&gt; and successfully compiled and programmed the PIC, the LCD will show "I'm alive... :-)" on the upper row.&lt;br /&gt;&lt;br /&gt;The bottom row of LCD will show an incrementing number (row 2, column 1) and decrementing number (row 2,column  9)&lt;br /&gt;&lt;br /&gt;Pressing the switches will sound the buzzer. Either at 1000Hz or 1100Hz depending on which switch.  If the switch connected to PORTB 7 is pressed, the buzzer will sound at 1000Hz.&lt;br /&gt;Switch connected to PORTB 6 will sound buzzer at 1100Hz.&lt;br /&gt;&lt;br /&gt;The LED will blink alternately at 100ms interval. (as per line 18 &amp;amp; line 20)&lt;br /&gt;&lt;br /&gt;P/S. You can also make the buzzer sound 1000Hz at 100ms interval by changing line 21 to "if (PORTB.F2==1){&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-7862018613522018541?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/7862018613522018541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=7862018613522018541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7862018613522018541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/7862018613522018541'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lesson-2-part-2.html' title='Lesson 2  Part 2'/><author><name>9w2dtr</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-1327808432323990898</id><published>2008-04-09T18:26:00.000-07:00</published><updated>2008-04-09T20:14:53.658-07:00</updated><title type='text'>Lesson 2: Let's C some more... LCD now active</title><content type='html'>Hello Gangs,&lt;br /&gt;&lt;br /&gt;As I will be on assignment for next few days, I may not be updating this blog as fast (&lt;span style="font-style: italic;"&gt;so everyone can catch up and digest and read and test and loose some hairs&lt;/span&gt;)...  As mentioned earlier, we'll do the LCD next.  It will be much easier to learn C and the intricacies of PIC when you can see the result in more meaningful ways, more than just blinking LEDs and beeping sounds...&lt;br /&gt;&lt;br /&gt;Compile and burn the following codes to test your LCD.  &lt;span style="font-weight: bold;"&gt;Make sure you adjust the contrast setting on the development board&lt;/span&gt;.  Study the codes by referring to MikroC online help or the user manual...  I'll dissect the codes in the next posting as well as learn more C matters in next lesson...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_1vG-ByOII/AAAAAAAAAWk/sxKBbpl5r9A/s1600-h/002_b.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_1vG-ByOII/AAAAAAAAAWk/sxKBbpl5r9A/s320/002_b.gif" alt="" id="BLOGGER_PHOTO_ID_5187424511321061506" border="0" /&gt;&lt;/a&gt;Download &lt;a href="http://www.ziddu.com/download.php?uid=ZqudmJuqabOgnJSnr6yZlJyiYa6WlZSt1"&gt;Lesson 2 Project File&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-1327808432323990898?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/1327808432323990898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=1327808432323990898' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1327808432323990898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1327808432323990898'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lesson-2-lets-c-some-more-lcd-now.html' title='Lesson 2: Let&apos;s C some more... LCD now active'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/R_1vG-ByOII/AAAAAAAAAWk/sxKBbpl5r9A/s72-c/002_b.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4330031571040267766</id><published>2008-04-07T21:29:00.000-07:00</published><updated>2008-04-07T21:35:56.812-07:00</updated><title type='text'>Preparation for next lesson...  wire up the LCD...</title><content type='html'>I've be covering the LCD next.  I'll be using the 16x2 characters LCD.  As such, please prepare the necessary cable for the LCD unless you want to use jumpers.&lt;br /&gt;&lt;br /&gt;Having the LCD will make learning easier and faster.  As you develop you own codes, you are bound to have logical errors (&lt;span style="font-style: italic;"&gt;which are not detected by MikroC&lt;/span&gt;).  Using strategically embedded LCD updating codes, you can diagnose and troubleshoot you codes faster.&lt;br /&gt;&lt;br /&gt;The connection diagram (&lt;span style="font-style: italic;"&gt;copied from the development datasheet&lt;/span&gt;) is shown below.  &lt;span style="font-weight: bold;"&gt;Don't forget the power connections to the LCD &lt;/span&gt;(&lt;span style="font-style: italic;"&gt;not shown in the schematic below&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_r1xCfGNdI/AAAAAAAAAWc/gU0XADH2zT4/s1600-h/002_a.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_r1xCfGNdI/AAAAAAAAAWc/gU0XADH2zT4/s320/002_a.gif" alt="" id="BLOGGER_PHOTO_ID_5186728143700243922" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4330031571040267766?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4330031571040267766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4330031571040267766' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4330031571040267766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4330031571040267766'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/preparation-for-next-lesson-wire-up-lcd.html' title='Preparation for next lesson...  wire up the LCD...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_tMtO23Q5vm4/R_r1xCfGNdI/AAAAAAAAAWc/gU0XADH2zT4/s72-c/002_a.gif' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-2236171416218084116</id><published>2008-04-07T19:10:00.000-07:00</published><updated>2008-04-07T21:22:42.388-07:00</updated><title type='text'>Let's C...  Dissecting the codes</title><content type='html'>As a continuation to &lt;a href="http://microchippiclessons.blogspot.com/2008/04/lets-c-your-first-c-program-using.html"&gt;this blog entry&lt;/a&gt;, in this section, will start dissecting the C program to understand the what and why of the codes.  The codes shown below for reference...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_rUSCfGNcI/AAAAAAAAAWU/uSwRPqZri_Q/s1600-h/001_d.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_rUSCfGNcI/AAAAAAAAAWU/uSwRPqZri_Q/s320/001_d.gif" alt="" id="BLOGGER_PHOTO_ID_5186691327240582594" border="0" /&gt;&lt;/a&gt;Okay, lets start.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Comments&lt;/span&gt;&lt;br /&gt;As mentioned earlier, comments can use the // or /*...*/ format.  Thus, line 1-3 are just comments line.  It's good to start your program with comments on what the program is all about.  After developing million lines of codes, you'll appreciate how short your memory span is...&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;the &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;main() function&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;All complete C program &lt;span style="font-weight: bold;"&gt;MUST &lt;/span&gt;have what's call a &lt;span style="font-weight: bold;"&gt;main()&lt;/span&gt; function.  When CPU is ready for execution (&lt;span style="font-style: italic;"&gt;main CPU clock is stable&lt;/span&gt;), it will execute the first line in the main() function.  The format of the main() function is as follows:&lt;br /&gt;&lt;br /&gt;  void main(){&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        //your codes here&lt;/span&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;void&lt;/span&gt; means the main() function doesn't return any value when it exit (&lt;span style="font-style: italic;"&gt;finish running&lt;/span&gt;).  In normal PC programming, some software needs to inform the operating system something such as error code when it exit.  This doesn't apply to microcontroller.&lt;br /&gt;&lt;br /&gt;The curly braces are to signify the block of codes belonging to main().&lt;br /&gt;Do take note that you MUST NOT put a semicolon after the closing brace.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;the &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Setup&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; needed for PIC&lt;/span&gt;&lt;br /&gt;Line 6: &lt;span style="font-weight: bold;"&gt;TRISB = 0b1100000;  &lt;/span&gt;//Set PortB to all output&lt;br /&gt;&lt;span style="font-style: italic;"&gt;As pointed by 9W2GU, the comment is wrong...  it should say pin 6 &amp;amp; 7 as inputs, remaining are output.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;TRISB is a &lt;span style="font-style: italic;"&gt;special function register&lt;/span&gt; of PIC used to control the direction of PORTB.  If the bit is set (1) then the corresponding pin of PORTB is configured as input otherwise it will be configured as output.  By default, all ports pins are configured for input on power up.&lt;br /&gt;&lt;br /&gt;As you can see, using binary format make coding easier as you can see which pin is configured for what.  In C, binary numbers are preceded by 0b, hexadecimal numbers by 0x, octal numbers by 0.  Other numbers (&lt;span style="font-style: italic;"&gt;starting with 1 to 9&lt;/span&gt;) are considered as decimal.  Thus 0b10101010 = 0252 = 170 = 0xAA in binary, octal, decimal and hexadecimal.&lt;br /&gt;&lt;br /&gt;Also take note that the line ends with a semicolon (;).  This is the syntax of C language.  All statement &lt;span style="font-weight: bold;"&gt;MUST&lt;/span&gt; ends with semicolon.  Since the compiler ignore white spaces (&lt;span style="font-style: italic;"&gt;as well as carriage returns and line feed characters&lt;/span&gt;), the semicolon serve to tell the compiler where a statement ends.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;the &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Setup&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; needed for MikroC&lt;/span&gt;&lt;br /&gt;Line 7: Sound_Init(&amp;amp;PortB, 0);&lt;br /&gt;This line is needed for us to use the Sound_Play() function later in the program.  Open MikroC help and search for &lt;span style="font-style: italic;"&gt;Sound&lt;/span&gt; in the index.  The functions and how to use it are explained there.  In this example, we specify that we want sound to be generated on PORTB, pin 0.&lt;br /&gt;&lt;br /&gt;This is an example of a &lt;span style="font-style: italic;"&gt;library function&lt;/span&gt;.  The capabilities is provided by MikroC, not PIC directly.  MikroC will create the necessary PIC codes to perform the functions thus making our lives a lot easier.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;the &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;while(expr)&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; section, line 8 to 15&lt;/span&gt;&lt;br /&gt;the while statement is used to execute a block of codes bounded by the opening and closing braces.  The codes will execute and loop for as long as the &lt;span style="font-weight: bold;"&gt;expr&lt;/span&gt; expression evaluate to &lt;span style="font-weight: bold;"&gt;true&lt;/span&gt;.  In C, anything that is not zero (0) is true.  Thus, in this example, since we used while(1), the expr will always be true, thus the codes within the braces will execute indefinitely... infinite loop.&lt;br /&gt;&lt;br /&gt;Do take note that the expr is evaluated when the while statement is first encountered and re-evaluated after the last statement in the block is executed.  Thus, the while statement can be used to execute a block of code while certain condition is true.&lt;br /&gt;&lt;br /&gt;The while statement can also be a one liner such as &lt;span style="font-style: italic;"&gt;while(PORTA.F0==1);&lt;br /&gt;&lt;/span&gt;In the above example, the while statement will continue until PORTA pin 0 is pulled to the ground.  It's normally used to wait for a key to be pressed.&lt;br /&gt;&lt;br /&gt;The above example also bring up another very important C syntax...&lt;br /&gt;the &lt;span style="font-weight: bold;"&gt;= sign&lt;/span&gt; is used for assignment.  Thus when we write &lt;span style="font-style: italic;"&gt;TRISB = 0b11000000;&lt;/span&gt; the compiler will assign TRISB the value of 0b11000000&lt;br /&gt;the &lt;span style="font-weight: bold;"&gt;== sign&lt;/span&gt; is used for comparison.  Thus when we write &lt;span style="font-style: italic;"&gt;PORTA==0xFF&lt;/span&gt; we are asking the compiler to check if the value of PORTA is equal to 0xFF or not.  If equal then the expression is true otherwise will be set as false.&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0); font-style: italic;"&gt;A very common error is using = instead of == in conditional testing.&lt;br /&gt;Using = alone will result in the expression always evaluating to true...&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;the &lt;span style="font-weight: bold;"&gt;Actual&lt;/span&gt; codes... finally...&lt;br /&gt;Line 9: PORTB = 0b00000010;&lt;br /&gt;Here we are turning on pin 1 of PORTB.  It effectively switching off the LED connected to the pin.  Check the development board schematic to confirm this.&lt;br /&gt;&lt;br /&gt;Line 10: delay_ms(400);&lt;br /&gt;Another MikroC library function.  It causes the PIC to wait for 400 milliseconds.&lt;br /&gt;&lt;br /&gt;Line 11: PORTB = 0b00000100;&lt;br /&gt;Let's switch off pin 1 and switch on pin 2 to get the alternating blinking LEDs on pin 1 &amp;amp; 2.&lt;br /&gt;&lt;br /&gt;Line 12: delay_ms(400);&lt;br /&gt;Wait for 400 milliseconds again.  Without this delays, the LEDs will appear to lit continuously, because the on and off cycle to tooooo fast for the eyes to detect.&lt;br /&gt;&lt;br /&gt;the &lt;span style="font-weight: bold;"&gt;Conditional&lt;/span&gt; test&lt;br /&gt;Line 13: if (PORTB.F7==0) Sound_Play(1000,200);&lt;br /&gt;Line 14: if (PORTB.F6==0) Sound_Play(1100,200);&lt;br /&gt;Okay, remember the Sound_Init() line above?  If you notice, there's no port or pin information in Sound_Play() function.  It uses the information provided via the Sound_Init().&lt;br /&gt;&lt;br /&gt;In these two lines, we do what's call conditional testing.  We use the if statement... normal format as follows:&lt;br /&gt;  if(expr){&lt;br /&gt;      //execute if expr evaluate to true&lt;br /&gt;      }else{&lt;br /&gt;     //execute if expr evaluate to false&lt;br /&gt;      };&lt;br /&gt;&lt;br /&gt;Just as the while() statement, if statement can also be one liner.  Format is&lt;br /&gt;&lt;/span&gt;    if(expr) statement;&lt;br /&gt;&lt;br /&gt;In the example above, we are checking if PORTB pin 6 or 7 are pressed.  If pressed (0), then PIC execute the Sound_Play() function otherwise, PIC continue with the next statement.&lt;br /&gt;&lt;br /&gt;After execution of line 14, PIC will re-evaluate the while() statement.  Since the statement is true, PIC will loop back to line 9 and the process continue until you pull the plug...&lt;br /&gt;&lt;br /&gt;How's the first lesson... ready to give up yet?  Hang in there... there's more torture in the subsequent lessons...  With the few statements already explained above, you're ready to embark on your initial exploration...  Look into what library functions provided by MikroC...  commonly used functions are there...&lt;br /&gt;&lt;br /&gt;Okay, forgot to mention earlier...  &lt;span style="color: rgb(255, 102, 0);"&gt;MikroC already predefines the PIC registers based on the CPU selected when you create new project.  The register names are identical to the one used in the datasheet... eg, PORTA, PORTB, TRISA, ADCON1, ANSEL, etc.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Also, &lt;span style="color: rgb(255, 102, 0);"&gt;to refer to a single pin of any port, you can use the .Fn format.  Thus PORTA.F0 refer to PORTA, pin 0 whereas PORTE.F1 refer to PORTE pin 1.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-2236171416218084116?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/2236171416218084116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=2236171416218084116' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/2236171416218084116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/2236171416218084116'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lets-c-dissecting-codes.html' title='Let&apos;s C...  Dissecting the codes'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_tMtO23Q5vm4/R_rUSCfGNcI/AAAAAAAAAWU/uSwRPqZri_Q/s72-c/001_d.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-8587756501522341532</id><published>2008-04-07T17:40:00.000-07:00</published><updated>2008-04-09T18:23:52.440-07:00</updated><title type='text'>Let's C...  Your first C Program using MikroC</title><content type='html'>Orait gang,&lt;br /&gt;&lt;br /&gt;Here is your first program...  You just download the file, expand it into a directory, start MikroC, click on Project&gt;Open and select the L001 project file.  We'll use it to kick off things...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ziddu.com/download.php?uid=bK6hmZeubKyZnOKnZKqhkZSpYaqhnZyo4"&gt;Download First Project File&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You should jumper the wires as shown below, connections are:&lt;br /&gt;RB0 (PortB Pin 0) to the Speaker&lt;br /&gt;RB1 (PortB Pin 1) to one LED&lt;br /&gt;RB2 (PortB Pin 2) to another LED&lt;br /&gt;RB6 (PortB Pin 6) to one switch&lt;br /&gt;RB7 (PortB Pin 7) to another switch&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    Note:  In PIC and MikroC, pin are numbered from 0 to 7... not 1 to 8...&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_rBpifGNUI/AAAAAAAAAVQ/bBDgAMq1NM8/s1600-h/DSC00114.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_rBpifGNUI/AAAAAAAAAVQ/bBDgAMq1NM8/s320/DSC00114.jpg" alt="" id="BLOGGER_PHOTO_ID_5186670840246580546" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Before I explain the programming aspect of things, please burn the hex file to the board with your programmer (PICKIT2, ICD2, WinPic, ICProg, etc).  The program is designed to do the followings:&lt;br /&gt;1.  The LEDs will blink alternately upon power up.&lt;br /&gt;2. Depending on which switch is pressed, different beep sound will be generated by the speaker.&lt;br /&gt;3. If both switches are pressed, both beep sound will be heard.&lt;br /&gt;&lt;br /&gt;We'll use the simple program to explain a bunch of things needed, covering PIC and C Programming.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Creating new project in MikroC&lt;/span&gt;&lt;br /&gt;Start MikroC then click on Project&gt;New Project...&lt;br /&gt;Complete the top fields as shown (&lt;span style="font-style: italic;"&gt;project name, directory, description, CPU type, CPU speed&lt;/span&gt;)... then click (&lt;span style="font-style: italic;"&gt;checkmark will appear&lt;/span&gt;) on the following Device Flags and then click OK:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The following flags will be used for most of our initial programming.  Other flags will be addressed in later module.  As an exercise for you, you may want to refer the datasheet as to why I've selected these flags to be turned on...  the information is in the Special Features of the CPU section.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    _PLLDIV_1, &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _FOSC_HS,                &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _PWRT_ON,                &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _WDT_OFF,                &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _MCLRE_ON,               &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _PBADEN_OFF,            &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _LVP_OFF,                &lt;/span&gt; &lt;span style="font-family:courier new;"&gt;    _XINST_OFF, &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-style: italic;"&gt;Update (080410) You need to enable _CPUDIV_OCS1_PLL2 flag as well.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/R_rF5yfGNVI/AAAAAAAAAVY/ILncGC0wiiQ/s1600-h/001_a.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/R_rF5yfGNVI/AAAAAAAAAVY/ILncGC0wiiQ/s320/001_a.jpg" alt="" id="BLOGGER_PHOTO_ID_5186675517465965906" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;After clicking OK, you'll be presented with a blank screen...  so much work just to get a blank screen :-)&lt;br /&gt;&lt;br /&gt;On the blank screen, please type EXACTLY as shown below.  It's your first C program...  Mind the semicolons, braces...  C compiler is worse than lawyers...  missing one semicolon can make you loose your remaining hair...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_tMtO23Q5vm4/R_rHpSfGNWI/AAAAAAAAAVg/EPj-xyCP9i4/s1600-h/001_b.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_tMtO23Q5vm4/R_rHpSfGNWI/AAAAAAAAAVg/EPj-xyCP9i4/s320/001_b.jpg" alt="" id="BLOGGER_PHOTO_ID_5186677433021379938" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;As with any C compiler, white spaces are ignored thus the indentation is there to help us see the program structure...  the compiler will ignore it...&lt;br /&gt;&lt;br /&gt;In C, inline comments are preceded with //&lt;br /&gt;In C, block (&lt;span style="font-style: italic;"&gt;multiple lines&lt;/span&gt;) comments are enclosed with /* ..... */ as shown below&lt;br /&gt;/* This is a sample of multi lines comments&lt;br /&gt;note that this line doesn't require any preceding identifier&lt;br /&gt;and this is the last line.  */&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;After typing the codes, click on Project&gt;Build&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;IF&lt;/span&gt; you have done exactly as I outline above, the program should compile correctly...  The indication is at the bottom of the next screen shot.  You can then load the resulting hex file into your programming software to program the hardware with it...  &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Make sure you slide the RUN/PROG switch on the development board to PROG for programming and RUN for running the program.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_rLTCfGNXI/AAAAAAAAAVo/to0znKjNhmQ/s1600-h/001_c.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/R_rLTCfGNXI/AAAAAAAAAVo/to0znKjNhmQ/s320/001_c.jpg" alt="" id="BLOGGER_PHOTO_ID_5186681448815801714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Please use the chat box on the left or comments link for questions, clarifications.  So far, you've learn the process of creating a project in MikroC, entering (&lt;span style="font-style: italic;"&gt;more like copying&lt;/span&gt;) C codes into MikroC, compiling the code and taking the resulting hex code to program the device.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-8587756501522341532?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/8587756501522341532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=8587756501522341532' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8587756501522341532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8587756501522341532'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/lets-c-your-first-c-program-using.html' title='Let&apos;s C...  Your first C Program using MikroC'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/R_rBpifGNUI/AAAAAAAAAVQ/bBDgAMq1NM8/s72-c/DSC00114.jpg' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-5605717247504349442</id><published>2008-04-06T18:06:00.000-07:00</published><updated>2008-04-06T18:11:28.688-07:00</updated><title type='text'>New casing for the development board</title><content type='html'>I was looking for suitable casing for the development board...  I noticed the casing for the digital caliper was lying on the shelf gathering dust so...  in the spirit of recycling, the casing for the development board was born...  the 16x2 LCD was added to the box...  also fabricated the female-female jumpers needed for the lessons...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_l0myfGNQI/AAAAAAAAAUw/EJesq-14MKo/s1600-h/DSC00109.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/R_l0myfGNQI/AAAAAAAAAUw/EJesq-14MKo/s320/DSC00109.jpg" alt="" id="BLOGGER_PHOTO_ID_5186304655629890818" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-5605717247504349442?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/5605717247504349442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=5605717247504349442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5605717247504349442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5605717247504349442'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/new-casing-for-development-board.html' title='New casing for the development board'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tMtO23Q5vm4/R_l0myfGNQI/AAAAAAAAAUw/EJesq-14MKo/s72-c/DSC00109.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6646536414169966455</id><published>2008-04-01T00:46:00.000-07:00</published><updated>2008-04-01T00:49:02.127-07:00</updated><title type='text'>Introduction to PIC...</title><content type='html'>While waiting for board distribution, in between fabrication of the jumpers, maybe the gang can browse through this webBook for some introduction to PIC microcontroller.  Although the webBook refer to the PIC16F84, the concepts applies to the rest of PIC family...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.mikroe.com/en/books/picbook/0_Uvod.htm"&gt;&lt;b&gt;&lt;span style="font-size:6;"&gt;                   PIC microcontrollers&lt;/span&gt;&lt;span style="font-size:130%;"&gt;,&lt;i&gt; for beginners                   too&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6646536414169966455?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6646536414169966455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6646536414169966455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6646536414169966455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6646536414169966455'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/04/introduction-to-pic.html' title='Introduction to PIC...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-4678306664405562411</id><published>2008-03-31T06:30:00.000-07:00</published><updated>2008-03-31T06:42:30.134-07:00</updated><title type='text'>Arrival of the long awaited development board!</title><content type='html'>Finally, it arrived today and everything is packed nicely.&lt;br /&gt;&lt;br /&gt;Unfortunately, it only comes with 2 CD for the development board although we purchased 4 units. It also comes with a USB cable...&lt;br /&gt;&lt;br /&gt;Anyway, no big deal....here is the photo.. for a tease before being distributed to our buddies...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jMzsrLusGK0/R_DpMy2jB0I/AAAAAAAAAAk/cP68ebTswXg/s1600-h/DSCN4410.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_jMzsrLusGK0/R_DpMy2jB0I/AAAAAAAAAAk/cP68ebTswXg/s320/DSCN4410.JPG" alt="" id="BLOGGER_PHOTO_ID_5183899577121703746" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jMzsrLusGK0/R_DpMC2jBxI/AAAAAAAAAAM/TjTQz4Z1IBA/s1600-h/DSCN4405.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_jMzsrLusGK0/R_DpMC2jBxI/AAAAAAAAAAM/TjTQz4Z1IBA/s320/DSCN4405.JPG" alt="" id="BLOGGER_PHOTO_ID_5183899564236801810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_jMzsrLusGK0/R_DpMi2jByI/AAAAAAAAAAU/PpG0lTQjCKw/s1600-h/DSCN4399.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_jMzsrLusGK0/R_DpMi2jByI/AAAAAAAAAAU/PpG0lTQjCKw/s320/DSCN4399.JPG" alt="" id="BLOGGER_PHOTO_ID_5183899572826736418" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_jMzsrLusGK0/R_DpMi2jBzI/AAAAAAAAAAc/ij5bl4_vpC8/s1600-h/DSCN4402.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_jMzsrLusGK0/R_DpMi2jBzI/AAAAAAAAAAc/ij5bl4_vpC8/s320/DSCN4402.JPG" alt="" id="BLOGGER_PHOTO_ID_5183899572826736434" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-4678306664405562411?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/4678306664405562411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=4678306664405562411' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4678306664405562411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/4678306664405562411'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/arrival-of-long-awaited-development.html' title='Arrival of the long awaited development board!'/><author><name>9w2dtr</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_jMzsrLusGK0/R_DpMy2jB0I/AAAAAAAAAAk/cP68ebTswXg/s72-c/DSCN4410.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-1627374622454205869</id><published>2008-03-21T03:11:00.001-07:00</published><updated>2008-03-21T04:02:17.719-07:00</updated><title type='text'>Temptation... next round maybe...</title><content type='html'>Saw this unit on ebay selling for USD29 (+USD22 s/h)... even on single unit purchase it is only about RM175 total...  price inclusive on a 40-pin programming board...  It's an ICD2 clone...  it will allow in-circuit debugging for bunch of PICs...  may be something the gang want to consider later after initial hurdle of learning PIC and MikroC... just ways to spend more... :-)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i6.ebayimg.com/04/i/000/dc/76/1ad3_1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://i6.ebayimg.com/04/i/000/dc/76/1ad3_1.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;If you like making one yourself, &lt;span style="font-style: italic;"&gt;serial port based... not USB&lt;/span&gt;, you can find the details &lt;a href="http://www.sixca.com/eng/articles/icd2_clone/index.html"&gt;here&lt;/a&gt;.  I've built one before, it works...  Just that serial port based is slower, need a serial port and need external power...  USB version way too easy to use...&lt;br /&gt;&lt;br /&gt;The USB DIY version can be found &lt;a href="http://www.icd2clone.com/wiki/Main_Page"&gt;here&lt;/a&gt; but require some chips that might not be easily found at our regular shopping place...  that's why the ebay posting looks really tempting...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-1627374622454205869?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/1627374622454205869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=1627374622454205869' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1627374622454205869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/1627374622454205869'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/temptation-next-round-maybe.html' title='Temptation... next round maybe...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-8773490054945484150</id><published>2008-03-20T19:37:00.000-07:00</published><updated>2008-03-20T19:40:06.407-07:00</updated><title type='text'>Concise C Syntax Reference...</title><content type='html'>Okay gang...  here's your weekend reading material...  print it and keep it handy...  you gonna refer to it very often once you start programming later on...  BTW, it's a PDF... &lt;a href="http://www.mikroe.com/pdf/mikroc/c_syntax.pdf"&gt;C Syntax and Reference&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-8773490054945484150?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/8773490054945484150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=8773490054945484150' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8773490054945484150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/8773490054945484150'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/concise-c-syntax-reference.html' title='Concise C Syntax Reference...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3564662118939551065</id><published>2008-03-20T17:21:00.000-07:00</published><updated>2008-03-20T17:34:09.514-07:00</updated><title type='text'>The Jumpers... while waiting for delivery...</title><content type='html'>It's too bad that the board delivery is delayed...  well, rather than be saddened with it, might as well start something...&lt;br /&gt;&lt;br /&gt;As mentioned earlier, I wanted to make special jumpers to go with the new board...  here it is...  the material required are the pin headers, the mating socket, wires and heat shrinkable tubes...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tMtO23Q5vm4/R-L__CfGNJI/AAAAAAAAAT4/weh5OA7kF1c/s1600-h/DSC00041.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tMtO23Q5vm4/R-L__CfGNJI/AAAAAAAAAT4/weh5OA7kF1c/s320/DSC00041.jpg" alt="" id="BLOGGER_PHOTO_ID_5179983979893634194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Bend the sockets on the strip 90 degrees and hold it as in the photo...  By tilting the socket backward, melted solder will not flow into the socket making it useless...  solder at the center wings and crimp the wire after that...  doing it on the strip is much easier than holding single socket...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/R-L__ifGNKI/AAAAAAAAAUA/RYmUnf7ZNe4/s1600-h/DSC00043.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/R-L__ifGNKI/AAAAAAAAAUA/RYmUnf7ZNe4/s320/DSC00043.jpg" alt="" id="BLOGGER_PHOTO_ID_5179983988483568802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Do the same on the other ends to the pin headers...  just be careful because the plastic can easily melt...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tMtO23Q5vm4/R-L__ifGNLI/AAAAAAAAAUI/I9f48RO3L2E/s1600-h/DSC00044.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tMtO23Q5vm4/R-L__ifGNLI/AAAAAAAAAUI/I9f48RO3L2E/s320/DSC00044.jpg" alt="" id="BLOGGER_PHOTO_ID_5179983988483568818" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The pin header end after soldering and heat shrink tube applied...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/R-L__yfGNMI/AAAAAAAAAUQ/JMdJJCN0E9E/s1600-h/DSC00047.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/R-L__yfGNMI/AAAAAAAAAUQ/JMdJJCN0E9E/s320/DSC00047.jpg" alt="" id="BLOGGER_PHOTO_ID_5179983992778536130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The final result...  plug the pin into the socket to test for functionality...&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tMtO23Q5vm4/R-L__yfGNNI/AAAAAAAAAUY/xCVYUS3TZ0w/s1600-h/DSC00054.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tMtO23Q5vm4/R-L__yfGNNI/AAAAAAAAAUY/xCVYUS3TZ0w/s320/DSC00054.jpg" alt="" id="BLOGGER_PHOTO_ID_5179983992778536146" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Some of you might ask why all this trouble, so here's the reasoning...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The pin header will plug snug into the prototyping board and the socket will form reliable connections to the IDC headers on the development board&lt;/li&gt;&lt;li&gt;The heat shrink cover will do two things; prevent shorts and acting as strain relief thus, if properly made, the jumpers will last you a loooong time.&lt;/li&gt;&lt;li&gt;These jumpers are meant to bring the signal from the IDC headers to the prototyping board...  on the board itself, a normal hookup wires is enough...&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3564662118939551065?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3564662118939551065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3564662118939551065' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3564662118939551065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3564662118939551065'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/jumpers-while-waiting-for-delivery.html' title='The Jumpers... while waiting for delivery...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_tMtO23Q5vm4/R-L__CfGNJI/AAAAAAAAAT4/weh5OA7kF1c/s72-c/DSC00041.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-6927070752377480613</id><published>2008-03-20T04:57:00.000-07:00</published><updated>2008-03-20T05:04:39.597-07:00</updated><title type='text'>Board delivery</title><content type='html'>The board may not arrive this week. Latest info from the supplier, the board is still in the production department. It may arrive by next week and we should be able to start our lesson.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-6927070752377480613?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/6927070752377480613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=6927070752377480613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6927070752377480613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/6927070752377480613'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/board-delivery.html' title='Board delivery'/><author><name>9w2dtr</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-3161859554105819010</id><published>2008-03-18T20:30:00.000-07:00</published><updated>2008-03-18T20:43:01.334-07:00</updated><title type='text'>Let't get the ball rolling...</title><content type='html'>Okay, the gang members are now awaiting the delivery of our development board ordered from Futurlec recently...  Look up the board details &lt;a href="http://www.futurlec.com/PIC18F4550_Board.shtml"&gt;here&lt;/a&gt;...&lt;br /&gt;&lt;br /&gt;The board uses the PIC18F4550, one of the most powerful PIC with tonnes of features...  Very unlikely that one would use all the features on a single project...  Nonetheless, it's there when you need it...&lt;br /&gt;&lt;br /&gt;While waiting for the board to arrive, do the followings...&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download the &lt;a href="http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf"&gt;PIC18F4550 Datasheet from Microchip website&lt;/a&gt;...  If you have the resources, print it out as reference unless you do not mind flipping pages on your computer...&lt;/li&gt;&lt;li&gt;Download &lt;a href="http://www.mikroe.com/en/compilers/mikroc/pic/"&gt;MikroC from MikroElektronika&lt;/a&gt; for compiler...&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Start making the jumper wires...  I'll post some pictures how I intend to make mine...&lt;/li&gt;&lt;li&gt;Consider how to make casing for the board...&lt;/li&gt;&lt;li&gt;Consider buying &lt;a href="http://www.futurlec.com/LCDDisp.shtml"&gt;LCD display&lt;/a&gt;... most likely 16 by 2 characters...  Hitachi chipset please...  No need for graphic LCD for now... &lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Short technical spec is here... copied from Futurlec...&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana,arial,helvetica;color:#cc6600;"  &gt;&lt;b&gt;PIC18F4550 USB Development Board - Technical Data&lt;/b&gt;&lt;/span&gt;  &lt;p style="font-style: italic;"&gt;  &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt; • &lt;b&gt;Microcontroller:&lt;/b&gt; PIC18F4550-I/P&lt;br /&gt;• &lt;b&gt;Main Crystal:&lt;/b&gt; 20MHz&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;• &lt;b&gt;Speed:&lt;/b&gt; up to 5MHz&lt;br /&gt;• &lt;b&gt;Processor Language:&lt;/b&gt; PIC&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Memory&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;Program Flash Memory (Internal):&lt;/b&gt; 32kBytes&lt;br /&gt;• &lt;b&gt;RAM Memory (Internal):&lt;/b&gt; 2048 Bytes&lt;br /&gt;• &lt;b&gt;EEPROM Memory (Internal):&lt;/b&gt; 256 Bytes&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Input/Ouput&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;I/O Points Available:&lt;/b&gt; 35&lt;br /&gt;• &lt;b&gt;I/O Points Connection:&lt;/b&gt; Standard IDCC Connections&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;A/D&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;A/D Inputs:&lt;/b&gt; Yes - 13 Channels&lt;br /&gt;• &lt;b&gt;A/D Accuracy:&lt;/b&gt; 10-bit&lt;br /&gt;• &lt;b&gt;A/D Speed:&lt;/b&gt; 500Ksps&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;PWM&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;PWM Output Channels:&lt;/b&gt; Yes - 2 Channels&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Timers&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;Timers:&lt;/b&gt; Yes - One 8-bit Timer and Three 16-bit Timers&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Auxiliary Communication&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;RS232 Communication:&lt;/b&gt; Yes - 1 Channel&lt;br /&gt;• &lt;b&gt;USB Communication:&lt;/b&gt; Yes - 1 Channel&lt;br /&gt;• &lt;b&gt;SPI:&lt;/b&gt; Yes - 3-wire SPI Module&lt;br /&gt;• &lt;b&gt;I²C:&lt;/b&gt; Yes - with Master/Slave Mode&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Board Features&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;Pushbuttons:&lt;/b&gt; Yes - 4 Tactile Inputs&lt;br /&gt;• &lt;b&gt;LCD Connection:&lt;/b&gt; Yes - with Contrast Adjustment&lt;br /&gt;• &lt;b&gt;Indication Leds:&lt;/b&gt; Yes - 4 Red LED's&lt;br /&gt;• &lt;b&gt;A/D Inputs:&lt;/b&gt; Yes - 4 Adjustable Trimpots&lt;br /&gt;• &lt;b&gt;Speaker:&lt;/b&gt; Yes&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Ancillary Features&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;br /&gt;• &lt;b&gt;In-Circuit Programming:&lt;/b&gt; Yes&lt;br /&gt;• &lt;b&gt;Power-On Led:&lt;/b&gt; Yes - Red&lt;br /&gt;• &lt;b&gt;USB Power-Supply Led:&lt;/b&gt; Yes - Yellow&lt;br /&gt;• &lt;b&gt;Regulator Power-Supply Led:&lt;/b&gt; Yes - Green&lt;br /&gt;• &lt;b&gt;Program-Run Switch:&lt;/b&gt; Yes&lt;br /&gt;• &lt;b&gt;Reset Button:&lt;/b&gt; Yes&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Power Supply&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;Power-Supply:&lt;/b&gt; 7 - 12 Vdc&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-style: italic;"&gt; &lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Dimensions&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;font-size:-1;color:#000000;"&gt;&lt;br /&gt;• &lt;b&gt;LxWxH:&lt;/b&gt; 155mm x 90mm x 30mm&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-style: italic;font-family:verdana;font-size:-1;color:#000000;"   &gt;&lt;span style="font-family:verdana,arial,helvetica;color:#cc6600;"&gt;&lt;b&gt;Parts Supplied&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;• &lt;b&gt;Included Parts:&lt;/b&gt; PIC18F4550 Development Board, USB Download Cable, Download Software, Manual on CD, Examples and Sample Code,  Data Sheets on CD.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.futurlec.com/Pictures/PIC18F4550_Development_F600.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://www.futurlec.com/Pictures/PIC18F4550_Development_F600.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;font-size:-1;color:#000000;"   &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-3161859554105819010?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/3161859554105819010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=3161859554105819010' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3161859554105819010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/3161859554105819010'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/lett-get-ball-rolling.html' title='Let&apos;t get the ball rolling...'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2865116231154819529.post-5741866723257431357</id><published>2008-03-18T19:54:00.000-07:00</published><updated>2008-03-18T19:56:52.746-07:00</updated><title type='text'>First Blog Entry</title><content type='html'>Dear All,&lt;br /&gt;Welcome to my Microchip PIC Lessons Blog.  I'll be using this blog to provide lessons to my friends and those interested in learning about PIC...  I'm no trainer nor am I an expert of PIC...  I'll be sharing knowledge that I gather thus far and welcome exchange of ideas and comments on the subject...&lt;br /&gt;&lt;br /&gt;Let's get it moving...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865116231154819529-5741866723257431357?l=microchippiclessons.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microchippiclessons.blogspot.com/feeds/5741866723257431357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2865116231154819529&amp;postID=5741866723257431357' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5741866723257431357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2865116231154819529/posts/default/5741866723257431357'/><link rel='alternate' type='text/html' href='http://microchippiclessons.blogspot.com/2008/03/fisrt-blog-entry.html' title='First Blog Entry'/><author><name>Basir Atan</name><uri>http://www.blogger.com/profile/08898740657545856702</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
