Need help in MIkro C please.

Discussion in 'Programmer's Corner' started by kamel2913, Mar 6, 2015.

  1. kamel2913

    Thread Starter New Member

    Mar 6, 2015
    15
    0
    Hello guys,

    first I would apologise for my English since it's a bit weak.

    okay, well I have a small project to do this year ( a line follower), I have installed Proteus and MikroC, I'm learning how to work with them since I'm a begginer.

    anyway, I have made my circtuis in proteus here it is:
    [​IMG]

    and my MicroC porgram is:
    Code (Text):
    1.  
    2. void main(){
    3.  
    4. TRISA=0xFF; PORTA=0xFF;
    5. TRISC=0x00; PORTC=0x00;
    6.  
    7.  
    8.  
    9. for(;;){
    10.  
    11. if(RA0_bit==0 && RA1_bit==0 && RA2_bit==0){
    12. RC1_bit=0; RC2_bit=0; RC3_bit=0; RC4_bit=0;}
    13.  
    14. else if(RA0_bit==1 && RA1_bit==1 && RA2_bit==0){
    15. RC1_bit=1; RC2_bit=0; RC3_bit=1; RC4_bit=0;}
    16.  
    17. else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
    18. RC1_bit=0; RC2_bit=1; RC3_bit=1; RC4_bit=0;}
    19.  
    20. else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
    21. RC1_bit=1; RC2_bit=0; RC3_bit=0; RC4_bit=1;}
    22.  
    23. }
    24. }
    25.  
    as I said I'm a begginer and I know it's wrong, but could someone tell me where I'm wrong? what should I do to make the condition "if" work?

    Moderators note: Please use code tags for pieces of code
     
    Last edited by a moderator: Mar 6, 2015
  2. kamel2913

    Thread Starter New Member

    Mar 6, 2015
    15
    0
    update,
    I have re read my post, and I noticed that I have wrote the wrong code, I don't know how to edit my post here so I had to reply myself.

    my code is

    Code (Text):
    1.  
    2. void main(){
    3.  
    4. TRISA=0xFF; PORTA=0xFF;
    5. TRISC=0x00; PORTC=0x00;
    6.  
    7.  
    8.  
    9. for(;;){
    10.  
    11. if(RA0_bit==0 && RA1_bit==0 && RA2_bit==0){
    12. RC1_bit=0; RC2_bit=0; RC3_bit=0; RC4_bit=0;}
    13.  
    14. else if(RA0_bit==0 && RA1_bit==1 && RA2_bit==0){
    15. RC1_bit=1; RC2_bit=0; RC3_bit=1; RC4_bit=0;}
    16.  
    17. else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
    18. RC1_bit=0; RC2_bit=1; RC3_bit=1; RC4_bit=0;}
    19.  
    20. else if(RA0_bit==0 && RA1_bit==0 && RA2_bit==1){
    21. RC1_bit=1; RC2_bit=0; RC3_bit=0; RC4_bit=1;}
    22.  
    23.  
     
Loading...