Need help in MIkro C please.

Thread Starter

kamel2913

Joined Mar 6, 2015
43
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:


and my MicroC porgram is:
Code:
void main(){

TRISA=0xFF; PORTA=0xFF;
TRISC=0x00; PORTC=0x00;



for(;;){

if(RA0_bit==0 && RA1_bit==0 && RA2_bit==0){
RC1_bit=0; RC2_bit=0; RC3_bit=0; RC4_bit=0;}

else if(RA0_bit==1 && RA1_bit==1 && RA2_bit==0){
RC1_bit=1; RC2_bit=0; RC3_bit=1; RC4_bit=0;}

else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
RC1_bit=0; RC2_bit=1; RC3_bit=1; RC4_bit=0;}

else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
RC1_bit=1; RC2_bit=0; RC3_bit=0; RC4_bit=1;}

}
}
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:

Thread Starter

kamel2913

Joined Mar 6, 2015
43
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:
void main(){

TRISA=0xFF; PORTA=0xFF;
TRISC=0x00; PORTC=0x00;



for(;;){

if(RA0_bit==0 && RA1_bit==0 && RA2_bit==0){
RC1_bit=0; RC2_bit=0; RC3_bit=0; RC4_bit=0;}

else if(RA0_bit==0 && RA1_bit==1 && RA2_bit==0){
RC1_bit=1; RC2_bit=0; RC3_bit=1; RC4_bit=0;}

else if(RA0_bit==1 && RA1_bit==0 && RA2_bit==0){
RC1_bit=0; RC2_bit=1; RC3_bit=1; RC4_bit=0;}

else if(RA0_bit==0 && RA1_bit==0 && RA2_bit==1){
RC1_bit=1; RC2_bit=0; RC3_bit=0; RC4_bit=1;}
 
Top