Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

PIC(18F) Microcontroller Programming in C (I/O Interfacing)

This is PIC Microcontroller 1st tutorial and in this tutorial we are going to learn, how to interface I/O Ports with PIC Microcontroller. PIC(18F4550)  Microcontroller has 5 I/O Ports(A,B,C,D,E) those can work both as Input and  Output. To program PIC Microcontroller in C you need MPLAB IDE which can easily be downloaded from Microchip’s site.

  1. To make any Port I/O you need to remember one keyword which is TRISX (X is Port Name you are using). Now if you write TRISB=1 this will make Port B as Input and writing TRISB=0 make Port B as Output.
  2. Lets see a program in which Microcontroller gets Input from Port B and display Output at Port A. The program begin by writing #include where p18f4550.h is the header file you need to attach with your Project. Click here to see how to attach files in MPLAB IDE.
    #include  Header File attached to Project
    void main()
    {
    TRISB=1;              Make Port B as Input
    TRISA=0;              Make Port A as Outputwhile(1)              Super loop
    {
    PORTA=PORTB;          Copy Data at Port B to Port A}
    }
     
     
  3. while(1) {  …….} is called the Super loop and is used when you are using file for hardware.
  4. This program will continuously copy data from Port B to Port A. If you need to See the Program working in your computer you can download PIC Simulator IDE and watch your program working.
  5. Keep trying these type of Programs. Enjoy…

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews