Header Ads

Blinking LED use PIC Microcontroller and Mikor C



In this Tutorial we will learn how to blinking LED use PIC Microcontroller. Here I am use PIC16F877A Microcontroller and 8MHz quartz crystal. You con watch the following video or read the written tutorial below.





PIC16F877A Microcontroller has A0-A7, B0-B7, C0-C7, D0-D7 and E0-E2 input/output port. Some pins for these I/O port are multiplex with an alternative function for the peripheral feature on the device. In general, when a peripheral is enable, that pin may not used as a general purpose I/O pin.

The TRIS Register controls the direction of Input/Output port. Here PORTB is 8bit wide, bi-directional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an Input. Clearing a TRISB bit (=0) will make the corresponding PORTB pin an Output.





Circuit diagram:        
                   


Component needed for this Project

  1. PIC16F877A Microcontroller
  2. 8MHz Quartz Crystal
  3. Push button
  4. LED 5mm
  5. Resister: 10k ,1k
  6. Breadboard
  7. Jumper Wire
  8. 5V DC Supplay 

Code Explain:
Here I am use Mikro C compiler for code editing. In void main function I define RB0 pin is output by clearing TRISB register. Then we clear the PORTB register. In next, here I am use while loop for continues program execution. And then close the program.


Mikro C Code:



Click download button for hex code
download

No comments

Theme images by 5ugarless. Powered by Blogger.