Slow response time between C# and mega2526

I'm certain that I'm in the wrong forum.
My question is. Is there any way to increase the response time between a C# program to the Arduino and vice versa?
If in fact, this is the wrong forum could someone send a link to the proper forum?
Many thanks in advance. PS I'm somewhat of a newbie.

What sort of change are we talking about here?
You need to hang numbers and units on this sort of question

I don't understand your question.

How are the 2 systems communicating ?

If it is a serial link then does the C# program keep the serial link open or does it open and close it as part of the communication protocol ?

It stays open.


data = Serial.readString();

A very simple way to increase the response time is to add a massive delay.

How would adding a delay increase the response time between reading and writing?

I have this delay:
s1. write(servoval);
delay(10); // wait for servo to finish

You are using Serial.readString();

From Serial.readString() - Arduino Reference

Serial.readString() reads characters from the serial buffer into a String. The function terminates if it times out (see setTimeout()).

What is the timeout set to ?

By increasing the amount of time between a stimulus and a response.
That's what "increase the response time" means.

Herr's the code, I hope it helps someone solve my problem.


String data;
char d1;
String x;
int servoval;
Servo s1;

void setup() {
  // put your setup code here, to run once:
 pinMode (13, OUTPUT);
 pinMode (9, OUTPUT);
 s1.attach(9);        // make output 9 the servo channel
void loop() {
  // put your main code here, to run repeatedly:
  data = Serial.readString();
  d1 = data.charAt(0);
  switch (d1){       // select action based upon first character
    case 'A':       // first character is an A = turn on pin 13 led
    digitalWrite (13, HIGH);
    digitalWrite (9, HIGH);
    case 'a':       // first character is an A = turn off pin 13 led
    digitalWrite (13, LOW);
    digitalWrite (9, LOW);
    case 'S':       // first character is an S = set servo angle
    x = data.substring (1);
    servoval = x.toInt();
    s1. write(servoval);
    delay(10);     // wait for servo to finish

Personally I would not read the input into a String

See Serial input basics - updated for better alternatives

Can you make any suggestions for my program?

You never answered what the Serial timeout is set to

Don't use readString

Don't use Strings at all

If you look at the program, I don't have a serial time-out.

What do you suggest I use?

Oh yes you do !
The default is 1 second

Could that be your problem?


How and where do I change it?