Thursday, August 4, 2011

PIC Programs 03: 8 LED chaser

Chasers are as old as electronics. So lets have our hands on it. Lets make an 8 LED chaser using PIC16F877A.  Eight LEDs are connected to the eight pins of PORTB as shown in circuit. Please note that it is not safe to connect LED directly to the PORTB. Always follow the practice of connecting a series resistance with and LED. 

For proper working of the  above program set your configuration bits to 3F7A.Compile the program using HI-TECH C.

The complete program and the circuit diagram are given below.


PROGRAM


#include

#define _XTAL_FREQ 12000000 //setting the crystal frequency to 12MHz

void main()
{

PORTB = 0xff; 
TRISB = 0x00; //Sets port B as an output port

while(1)
{

PORTB=0b10000000;
__delay_ms(100);
PORTB=0b01000000;
__delay_ms(100);
PORTB=0b00100000;
__delay_ms(100);
PORTB=0b00010000;
__delay_ms(100);
PORTB=0b00001000;
__delay_ms(100);
PORTB=0b00000100;
__delay_ms(100);
PORTB=0b00000010;
__delay_ms(100);
PORTB=0b00000001;
__delay_ms(100);
}
}

CIRCUIT DIAGRAM




download the c program file


download the hex file







1 comments:

Anonymous said...

please provide dragging effect code. i mean followed led to be off with fading effect. thank you. jaya19995@gmail.com
thank you

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes