Robin2:
You may be able to solve your problem with suitable Arduino code.Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.
...R
Thank you, but the problem persists. I have used the second example to go through all the characters until '\n' is detected (code bellow), but unless I select "No line ending" mode on Serial Monitor, it yields the same two iterations instead of one.
const int trig_out = 5;
const int trig_in = 6;
int np = 11;
int count;
char dummy='a';
char endMarker = '\n';
void setup() {
pinMode(trig_out,OUTPUT);
pinMode(trig_in,INPUT);
digitalWrite(trig_out,LOW);
Serial.begin(9600);
}
void loop() {
while(!Serial.available()){} //wait until something is ready to be read
while(Serial.available()&&dummy!=endMarker){
dummy=Serial.read();
}
for(count=0; count<np; count++){
digitalWrite(trig_out,HIGH);
delay(100);
digitalWrite(trig_out,LOW);
}
delay(1000);
}