| /* Project Name: PushButton for Led Chaser */ #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=5 /* defines memory location of register */ #byte portb=6 /* defines memory location of register */ void main() { byte c,d; set_tris_a(0x01); /* it sets the portA RA0 as input port */ set_tris_b(0x00); /* it sets the portB RB0 as output port */ while(true) { if(porta == 0x01) /* if switch pressed starts Disco Led */ { while(true) { c = 0; /*initialize the count c equal to zero */ d = 0x01; /* assigns the content of d to 0x01 */ while(c < 8) { portb = d; /*sends content of d to portb to turn-on 1st Led*/ delay_ms(250); /* creates 0.25 second delay */ d = d << 1; /* shifts the value of data to the left by 1*/ c++; /* increments the value of c by 1*/ } if(porta == 0x01) /*if switch pressed again stops DiscoLed*/ { portb = 0x00; /*assigns portB RB0 to 0x00 to turn-offLed*/ break; /* comes out of the loop*/ } } } } } |
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.
PushButton for Led Chaser with microcontroller
Subscribe to:
Post Comments (Atom)
Recent Comments
Popular Projects
Sites U missed to visit ...
Give Support
Encourage Me through Comments
No comments:
Post a Comment