pic16f877a and mikroc problem

Status
Not open for further replies.

Thread Starter

wali78

Joined Dec 29, 2014
28
Hi, it would be nice if somebody can help me in my project, I try to control 6 relays with different times and repeating some operations, below is the code in MikroC, it doesn't work correctly. I hope to find a solution here.

void main() {

TRISB=0b00000000;
PORTB=0; {
for(;
{

RB1_bit=1;
Delay_ms(5000);
RB1_bit=0;
delay_ms(2000);

RB2_bit=1;
delay_ms(5000);
RB2_bit=0;
delay_ms(2000);

RB3_bit=1;
delay_ms(5000);
RB3_bit=0;
delay_ms(2000);


RB1_bit=1;
Delay_ms(5000);
RB1_bit=0;
delay_ms(2000);

RB5_bit=1;
Delay_ms(5000);
RB5_bit=0;
delay_ms(2000);

RB2_bit=1;
delay_ms(5000);
RB2_bit=0;
delay_ms(2000);

RB3_bit=1;
delay_ms(5000);
RB3_bit=0;
delay_ms(2000);


RB1_bit=1;
delay_ms(5000);
RB1_bit=0;
delay_ms(2000);

RB4_bit=1;
delay_ms(2000);
RB4_bit=0;
delay_ms(2000);

RB5_bit=1;
Delay_ms(5000);
RB5_bit=0;
delay_ms(2000);

RB2_bit=1;
Delay_ms(5000);
RB2_bit=0;
delay_ms(2000);

RB3_bit=1;
delay_ms(5000);
RB3_bit=0;
delay_ms(2000);

RB5_bit=1;
delay_ms(5000);
RB5_bit=0;
delay_ms(2000);

RB7_bit=1;


}
}
}





Many thanks for the quick response, I want to tun on/off the relays as follow:
Ex.
{
Relay 1 ON/OFF (delay time)
after that
Relay 2 ON/OFF (delay time)
after that
Relay 3 ON/OFF (delay time)

And then,
Relay 1 ON/OFF
after that
Relay 5 ON/OFF (delay time)
after that
Relay 2 ON/OFF (delay time)
after that
Relay 3 ON/OFF (delay time)

And then,
Relay 1 ON/OFF (delay time)
after that
Relay 5 ON/OFF (delay time)
after that
Relay 4 On/OFF (delay time)
Relay 2 ON/OFF (delay time)
after that
Relay 3 ON/OFF (delay time)

And then,
Relay 5 ON/OFF (delay time)

And then,
LED 7 ON
}
 
Status
Not open for further replies.
Top