difenbahij:
if available() gets the number of bytes arrived and stored in the serial recieve buffer, how come the result of the code bellow is just printing.
(when i lunch the program, the result on the serial monitor is: printprintprintprintprint....)char inByte = 0;
void setup (){
Serial.begin(9600);
}void loop ()
{
Serial.print("print");
while (Serial.available()>0){
inByte = Serial.read();
Serial.print(inByte);
}
}What should i do program to stop after serial.print("print")
(print and then wait till you recieve at least 1 byte)thank you very much
char inByte;
if (Serial.available())
{
inByte = Serial.read();
Serial.print(inByte);
}
///if there's nothing there, it will loop and start again, it does not 'wait' it simply gives yes/no answer and then you get the data.