int D=1000,ND=0; int mode=0; void setup() { pinMode(13, OUTPUT); Serial.begin(115200); } void loop() { digitalWrite(13, HIGH); delay(D); digitalWrite(13, LOW); Serial.print("Q="); Serial.println(D); Serial.print("T="); Serial.println(millis()); delay(D); } void serialEvent() { while (Serial.available()) { char inc = (char)Serial.read(); if (mode==0 && inc=='D') { mode=1; ND=0; } if (mode==1 && inc=='E'){ D=ND; mode=0; ND=0; Serial.print("D="); Serial.println(D); } if (mode==1 &&(inc>='0'&& inc<='9')){ ND=ND*10+(inc-'0'); } if (mode==0 && inc=='Q') { Serial.print("D="); Serial.println(D); } } }