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.

Question on simple c programming...

Status
Not open for further replies.

mohideen

Member level 2
Joined
Jan 19, 2011
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,580
Hi all,
I have 4 switches controlling a function.
I am using and if-else statement for this.
However i am receiving error for doing this,
if((PORTEbits.RE0==0^PORTEbits.RE1==0)&&(PORTE.RE2==1&&PORTB.RB0==1))// Either S4 is ON or S5 is ON while RE2 & RB0 is OFF
Isit wrong or is there other way for accomplish it?
Thanks :)
 

Code:
while(PORTE.RE2 == 1 && PORTB.RB0 == 1)
{
   if ( PORTEbits.RE0 == 0 || PORTEbits.RE1 == 0)
   { 
      //do something
   }
}
 

Thanks:)
....

---------- Post added at 19:18 ---------- Previous post was at 19:06 ----------

How do i use else if later on??
I am recieving errors?
 

Yes, the logical OR operator is the || and not the ^ what you have used, mohideen.

@miskol
It is unfortunate the while loop here (it may be unnecessary to wait will be),
the original "multiple if" structure doesn't wait

And an ELSE statement is also possible later ...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top