Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to blink of each bit of port in pic

Status
Not open for further replies.

thannara123

Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,580
Helped
122
Reputation
244
Reaction score
114
Trophy points
1,353
Location
India
Activity points
10,388
Hai experts i need to a program to blink led PORT1,PORT2,PORT3 etc of any port of pic 16f877a
ie i want to do blink led 's first blink led1 which is connected to PORTA of bit 0, next it connected to Porta of bit 1 ..etc
in mikroc pro
pleas help me
 

You can do something like

I assume that the led light with a logic 1 in the pin,

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
for (i=0;i<8;i++)
 {  PORTA=(1<<i)  // 1 shifted left i times
    some delay here
 }
PORTA=0;  // turn everything off
 
for (i=0;i<8;i++)
 {  PORTB=(1<<i)  // 1 shifted left i times
    some delay here
 }
PORTB=0;  // turn everything off



you can do the rest.
also check if one of your ports has less than 8 bits (pins) and change i accordingly

Alex
 

thanks for reply


at last i write the program
it is working fine
thanks again


void main() {
trisa=0;
trisb=0xff;
while(1)
{
if(portb.f0==1)

porta=255;
else
{
porta=0x00;
}
}}
 
  • Like
Reactions: hdesys

    hdesys

    Points: 2
    Helpful Answer Positive Rating
Your code turns on/off the complete port is that what you want?
I thought you asked for the running led effect,
turn on portA bit 0 to bit7 (one at a time) then portB bit0 to bit7 etc.

Alex
 

Hi, I'm working hard to learn PIC 16F877A and is making LED lights on and off, controlled by the switch, can send me the code for learning purposes. Thank you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top