Search

Thursday, August 21, 2014

LED Interface With PIC18f4520

Blink

           This example shows the simplest thing you can do with Pic microcontroller to see physical output: it blinks an LED.

Hardware Required

  • Pic microcontroller
  • 8-LEDS
  • 8-220 ohm res

Circuit

          To build the circuit, attach a 220-ohm resistor to port C. Then attach the long leg of an LED (the positive leg, called the anode) to the resistor. Attach the short leg (the negative leg, called the cathode) to ground. Then plug your PIC18f4520 into your computer, start the Pic program, and enter the code below.
          Most Arduino boards already have an LED attached to port c on the board itself. If you run this example with no hardware attached, you should see that LED blink.
//****************************************//

Program:

//Author : Palak Patel
//Contact No:9173211683
//Title:Led Blinking
//Platform: PIC18f4520
//Software:MPLAB


#include<p18f4520.h>
#define LED PORTC
void Delay();

void main()
{
TRISC=0x00;         //PORTC as a output PORT
                             //LED BLINKING
while(1)
{
LED=0x00;     //Led OFF
Delay();
LED=0xFF;    //Led ON
Delay();
}
}

void Delay()
{
unsigned int i;
for(i=0;i<2000;i++);

}
//****************************************//

Simulation:









                                                     For Basic Electronics Kindally follow this Link:
                           http://basicelectonicspalakpatel.blogspot.in/2014/08/the-mosfet-as-switch.html

No comments:

Post a Comment