char junk;
String inputString="";
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(10,OUTPUT);
pinMode(7,OUTPUT);
}
void loop()
{
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read();
inputString += inChar;
}
Serial.println(inputString);
while (Serial.available() > 0)
{
junk = Serial.read() ;
}
if(inputString == "a")
{
digitalWrite(13, HIGH);
}
else if(inputString == "b")
{
digitalWrite(10, HIGH);
}
else if(inputString == "c")
{
digitalWrite(7, HIGH);
}
else if(inputString == "x")
{
digitalWrite(10, LOW);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
}
inputString = "";
}
}
Comments