Saturday 11 April 2015

Logical Operations

|| -- logical OR
&& -- logical AND
! -- logical NOT

logical AND

void setup(){
Serial.begin(9600);
Serial.println("checking the use of &&(logical AND) operator");
}

void loop(){
Serial.println("enter character or number");
while(!Serial.available()){
//wait until user enters the data
}//end of while

if(Serial.available()){
char ch = Serial.read();
Serial.println("the character");
if((ch = '0')){
Serial.println("you entered a number ");
Serial.print("the Number is \t");
Serial.print(ch - '0');
Serial.print("\n");
}else{
Serial.println("you entered character");
Serial.print("the chraracter you entered is\t");
Serial.print(ch);
Serial.println("");
}//end of If-Else condition
}//end of If condition
}//end of loop

No comments:

Post a Comment