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 I hope you understand the question.