LED on/off with delay

Flowchart Explanation:
Set the Port B of the PIC 16F84A device as output Port. Turn the Led-on by sending the data one to the Port B and create a Delay of 0.5 seconds to keep the Led in on-state. Turn the Led-off by sending the data zero to the Port B and create a Delay of 0.5 seconds to keep the Led in off-state. this process is repeated untill the power supply to the PIC 16F84A goes off.
Flowchart and Circuit Diagram:

Circuit Description:
PIC 16F84A microcontroller device is programmed to turning a LED on/off continuously with delay. this device uses 4MHz crystal/Resonator oscillator to drive osc1 and osc2. Port B RB0 is used as output port and it output the positive current with some delay to blink the LED and this delay timing depends on the program. A 100 or120 ohms resistance is connected to the LED to limiting the output current from RB0. VDD(Pin 14) and pin 4 is connected to the +5V power supply. Vss(Pin 5) is connected to the -5V or ground.
Embedded C Program: LED on/off with delay
 PIC CCS C compiler
Embedded C program for Turning a Led On/Off with delay. its very easy to learn and you can able to understand the concept and logic of the program from the flowchart and comment lines of the program.

/*Project Name: LED on/off with 0.5 second delay*/

#include<16F84A.h>   /*defines type of device to include device files*/

#use delay(clock=4mhz)     /* defines crystal frequency 4MHz */

#fuses xt, nowdt, noprotect, noput
/* xt oscilator used and no watch dog timer, no code protection, no     power up timer is used */

#byte portb=6                  /* defines memory location of register */

void main()
     set_tris_b(0x00);        /* it sets the portb as output port */

     loop1: portb=0x01;    /* sends 1 to portb RB0 to turn the LED-on */

     delay_ms(500);    /* creates half second delay between LED on/off*/

     portb=0x00;            /* sends 0 to portb RB0 to turn the LED-off */

     delay_ms(500);     /*creates half second delay between LED off/on*/

     goto loop1;
     /* loop1 just turns-on/off the LED continuously until the power supply             OFF */

 delay is used to keep the processor output as constant for the period of specified time. this period of time is called as Delay time. Delay time can be programmed according to your specified timings. for example
delay in milli seconds
delay in seconds

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Engr.Arif Naseem | Bloggerized by Naseem - | Affiliate Network Reviews