if statement with multiple conditions

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fprete
 
Posts: 110
Joined: Mon Feb 09, 2015 3:06 pm

if statement with multiple conditions

Post by fprete »

Friends:

In an if statement, if I want to indicate that any one of several inputs to the serial port should cause an event to occur, how is it coded? For instance, if I want a pin set high, or to serialPrint something if the serial port receives the character "a", the code might read as follows:

if (Serial.available() > 0);
{
char letter = Serial.read();
if (letter == 'a')
{
Serial.println (F("ON"));

However, what if I want the same thing done-- i.e., Serial.println (F("ON"))-- if the port receives an "a", or "b", or "c"?

I cannot seem to find an informative answer or tutorial.

Thank you in advance.

User avatar
Franklin97355
 
Posts: 23940
Joined: Mon Apr 21, 2008 2:33 pm

Re: if statement with multiple conditions

Post by Franklin97355 »


User avatar
fprete
 
Posts: 110
Joined: Mon Feb 09, 2015 3:06 pm

Re: if statement with multiple conditions

Post by fprete »

Thank you very much.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”