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:/*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 in milli seconds | delay in seconds |
250 | 0.25 |
500 | 0.5 |
1000 | 1 |
2000 | 2 |
No comments:
Post a Comment