int CharacterCount = 0;
void setup()
{
Serial.begin(9600);
Serial.println("\r\rInput Characters Activity:");
Serial.println();
}
void loop()
{
char InputCharacter;
if (Serial.available() > 0)
{
InputCharacter = Serial.read();
// The if statement is required when using the Serial Console
// in the Arduino IDE. This is because of the inclusion of the
// Enter key (ASCII - 0x0A) to acknowledge Serial data inputs.
// Putty receives each character automatically, without the need
// of the enter key. Therefore, the if statement is not required.
if (InputCharacter != 0x0A)
{
CharacterCount += 1;
Serial.print("Input Character: ");
Serial.print(InputCharacter);
Serial.print("\tInput Character (ASCII-hex): 0x");
Serial.print(InputCharacter,HEX);
Serial.print("\tCharacter Count: ");
Serial.println(CharacterCount);
}
}
}