Accept pc keyboard commands without pressing an enter button

Hi! I'm new to the arduino world and need some help..

Is there any way that arduino accept pc keyboard commands without pressing enter button as confirmation in "Serial Monitor"?

Here is my simple test code:

int ledPin = 13;

void setup()
{
  Serial.begin(9600); 
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  while (Serial.available() == 0);
  int val = Serial.read() - '0';  
  

  if (val == 1) 
  {
    Serial.println("SVIJETLI"); 
    digitalWrite(ledPin, HIGH);
  }
  
  
  else if (val == 0)
  {
    Serial.println("NE SVIJETLI");
    digitalWrite(ledPin, LOW);
  }
  
  
  else if(val == 2)
  {
    Serial.println("Unesi broj blinkanja: ");
    while (Serial.available() == 0);
    int br=Serial.read()-'0';  
    for(int x=0; x<br; x++)
        {
          digitalWrite(ledPin, HIGH);
          delay(700);
          digitalWrite(ledPin, LOW);
          delay(700);
        }
       Serial.println("Broj blinkanja" br);
   }
   
   
   else
   {
     Serial.println("KRIVI UNOS");
   }
   Serial.flush();
}

Every time i need to press Enter button for confirmation...

Thanks in advance, and sorry for my bad english :slight_smile: I hope you understand the question.

I think the Arduino IDE only sends the input line to the Arduino when you press enter.

If you really need to be able to send one character at a time, you could use hyperterminal instead.

Use another terminal program, one that sends characters as you type them.

Putty
Hyperterm
Realterm
???

Sorry I'm having a senior moment and can't think of any more but there are 100s.


Rob

Thanks for your answers. Using putty and works like a charm :slight_smile: