Thursday 9 April 2015

Checking the char is digit or not ?


/*
Author : kunchala Anil
checking that if entered char is digit or not
*/
void setup(){
Serial.begin(9600);
}//end of setup()

void loop(){
Serial.println("enter char");
while(!Serial.available()){
//wait until user enters data
}
while (Serial.available()){
char ch = Serial.read();
Serial.print("the character you entered ");
if(isdigit(ch)){
Serial.print("is digit\n");
}else{
Serial.print("not digit\n");
}//end of If
}//end of while
}//end of loop

and the result is
isdigit

Note the Noline ending and baud rate at serial monitor

No comments:

Post a Comment