Hello, I download Arduino Serial Sample and Upload program to my arduino Uno, but when I write "a" or "b" in Arduino Serial Sample Example nothing happened and led don't blink....
List code
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
int led = 13;
void setup() {
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
}
void loop() {
// print the string when a newline arrives:
if (inputString="a") {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (inputString="b") {
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level)
// clear the string:
inputString = "";
stringComplete = false;
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString +=inChar;
}
}