Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

Beginners guide to the PIC Microcontroller


This guide will show you what a PIC microcontroller is and what you can do with it.

First of all what is a PIC microcontroller?

A microcontroller is a self contained fully functional computer with built in peripherals.

The idea of a microcontroller is that it can stand alone and does not require any other circuitry to do a useful task.  Normal processors such as those found in desktop PCs require a multitude of circuitry before you can get anywhere near a useful system.

Another important point about a microcontroller is that it is not intended to be a super-duper all singing all dancing mega MIP device it is intended for doing fairly simple tasks that do not require huge amounts of processing power.

Note : You can now get DSP microcontrollers which do allow very complex operation at high speed - but these require advanced knowledge of signal processing mathematics.


Having said that a microcontroller is actually extremely efficient for doing fairly simple tasks for the simple reason that it has built in peripherals.

These include such as timers, ADCs, analogue comparators, pulse width modulators, USARTs...and more.  
Ths is one I find amazing the 12f675 is has only 8 pins (the same as a 555).

It has :

*Two timers.
*One analogue comparator.
*10 bit 4 input ADC.
*Six usable I/O pins (you need one for power and and one for Ground)
*1024 program memory words (program space).
*64 Bytes Ram
*128 bytes EEPROM
*Internal oscillator.
*External clock capable to 20MHz
*ICSP port.

Phew - just compare that to a 555  = 1 comparator!

A 12F675 tutorial is available on the site.

However I would not recomment that you use it, as a beginner, since although it is a powerful device it only has 8 pins (two of which are power and ground). So pins are multiplexed for programming and for use. This makes it more difficult to use since you have to program the device then set it up for use.

If you use a larger pinned device such as a 16F628 (18pins), 16F88 (18 pins) or a 16F877 (40 pins) or even 18F2550 (28 pins) or 18F4550 (40pins) then you are going to find it a lot easier to allocate pins to different functions - and you can leave the programmng port connected to only the ICSP programmer while experimenting with the other pins of the device..

Low pin count devices are really for a finalized "minimized" project - e.g. if you are building a small footpring PCB then the smaller devices will save money. Go for larger ones for experimentation (they also have more RAM and Flash program memory (EEPROM) making it easier to create programs..

The other point is that most internal peripherals work in more-or-less the same way even between different families i.e. 12F, 16F, 18F - of course there are enhancements but the basic functionality is the same e.g.. for timers and comparators etc.

Simple Tasks

Actually the 'simple tasks' are only simple in comparison to the computing power of a PC.  In reality the microcontroller is ideal for tasks that require low level hardware control.

These ready-to-use peripherals save you from having to wire up extra circuitry all you have to do is program the internal peripheral to configure the microcontroller for your application.

Project examples

Examples of what you can make using a microcontroller are:

*Inductance/Capacitance meter.
*Ultrasonic range finder.
*Universal Infrared controller.
*Frequency counter.
*X10 home automation controller.
*Metal detector.
*Home security alarm.
*Servo controller.
*Dot matrix led controller.
*Binary clock.
*Seven segment Digital clock.

...and many more...

... In fact the list is endless because
you can make up virtually any electronic
project you can think of and...

...a microcontroller makes it easy.

The website and this guide focus on only a few microcontrollers in the PIC range since all PIC devices share common internal  peripherals (so learning about a peripheral means you have learned the peripheral for all PIC devices):

12F675 - 8 pin.
16F88 - 18 pin.
16F877 - 40 pin.

Note: Sometimes there are small differences - so check the data sheet - but in general the peripherals are identical across the same range of devices.

Structure of a microcontroller


All microcontrollers have a Central Processing Unit (or CPU) and this is responsible for taking the data, processing it and spitting out a result.

For the PIC microcontroller mid range devices (16F) the processing block is 8 bits wide so the microcontroller works only with data having 8 bits in it.


PIC Microcontrollers have three types of memory:

  1. Program memory.
  2. Data memory.
  3. EEPROM memory
Memory Architecture

PIC devices use a Harvard architecture which simply means that Data memory and Program memory are entirely separate.   

The idea is that you can get a speed improvement by storing the program and the data  in separate memory sections because you can retrieve data from both sections at the same time.  

For a von-neumann architecture (where the same memory is used to store program and data) the processor has to fetch the program instruction and then fetch the data so it works more slowly.

For this reason you will see references to the PIC saying it has 12bit or 14bit architecture etc. - this refers only to the program memory - all you really need to know is the data memory size as this is the fundamental unit that the microcontroller operates on - it's usually 8 bit.

Program memory

Program memory is based on Flash technology (this is the 12bit or 14bit spec.).  This is non volatile memory which stores your program instructions.

Note: non-volatile means that it keeps its contents even when the power is turned off so it's ready to go as soon as power is applied.

This is also the memory that you program using an external programmer (using the PIC ICSP port) and programmed from a PC using the programming software e.g. ICPROG.

Data memory

Data memory is simply memory based on SRAM technology.  This type of memory retains its values only while the power is on.

Unlike Flash memory you can easily change the values stored in data memory while the program is running.  

So you can create counters to store the number of events detected or temporarily store the intermediate result of a computation.  This is memory that stores changing data i.e. you store variables in Data Memory.

EEPROM memory

EEPROM memory is another data store - it's a cross between the program memory and data memory.  You can store any data in it and retrieve any data from it - but  it takes more effort to store and retrieve data.

This is because it is also non-volatile just like the flash memory but under program control you can change the stored values just like data memory but when the power goes off it keeps the stored values.

It is Electrically Erasable PROM : Non volatile Data Memory.

Note: Newer devices let you alter the program memory itself - which is why bootloading is possible.

EEPROM usage

For a normal program you would use EEPROM to store program settings that you need to keep between power cycling of the device.

For example if you had designed a programmable power supply you would want the microcontroller to remember the last voltage so the unit powers up to the same voltage at the next session.

Next time...

... Ports - Using microcontrollers to communicate with the 'real' world.

New! Comments

Have your say about what you just read! Leave me a comment in the box below.

Privacy Policy | Contact | About Me

Site Map | Terms of Use

Visit our Facebook Page:

   Click Here

  1. The TCS230 Color Sensing Chip: How it works and how to use it.

    How to use the TCS230 (/TCS3200) Color detector chip and easily add it to any of your projects.

    Read more

  2. How to use the ADXL345 for movement sensing and more.

    With the ADXL345 acellerometer you can detect up to 16g! You can also find out how to use it for tap detection and more.

    Read more

  3. How the HMC5883L 3-axis digital magentomter works

    HMC5883L - How make a digital compass, Find out the differences between the HMC5883L and the QMC5883L and whether they are compatible.

    Read more

  4. ESP8266 Arduino IDE setup.

    Easily use an ESP8266 with the Arduino IDE and program your first sketch into the ESP8266

    Read more

  5. How to use the MCP4725, a versatile and tiny (SOT-23-6) analogue output device

    The MCP4725 chip is a 12 bit DAC with memory that outputs voltage that you can use for many dfferent purposes. Find out what they are in this page.

    Read more

  6. PCF8591: An 8 bit ADC you can easily connect using I2C

    PCF8591: A four input ADC with single DAC. How good is this 8 bit ADC, and should you use it in your next project?

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's


- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan


"Awesome site,
very, very easy and nice
to navigate!"

- Matt

Learn Microcontrollers

"Interested in

Sign up for The
Free 7 day guide:


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."

- Dave


"Your site is a great
and perfect work.

- Suresh


"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.

- Anon

Back to Top