pic16f877a and mikroc problem

Discussion in 'The Projects Forum' started by wali78, Jan 2, 2015.

Thread Status:
Not open for further replies.
  1. wali78

    Thread Starter New Member

    Dec 29, 2014
    28
    0
    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(;[​IMG]{

    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
    }
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    One post is enough.
     
Loading...
Thread Status:
Not open for further replies.