I have had an application working for over a year now using an arduino to monitor some inputs and send the readings back to a PC over the serial port.
I am running at a board rate of 115200, but tried slowing down to 9600 with a genuine arduino and not got it working.
PC every 5 ms is sending a signal to the Arduino, which then truncates the digital inputs to a string and sends back a seriaes of 1s and 0s.
The clone is coping just fine and the PC is getting the signals back.
The genuine Arduino sends the first signal, then they start getting truncated and slow down until I am only getting a reply to around 1 request in 100.
I'f refitted the clone and got it working again, but stumped as to why a cheap Chinese clone was working and the genuine Arduino isn't. Guessing it is something to do with the CH340 and FTDI chips but I'm at a loss as to the actual cause.
PS, I know my code is flawed, I am still new to Arduinos and to programming in C, but it was and is working on a clone.
String incoming = "";
String inputs = "";
int I1 = 13;
int I2 = 14;
int I3 = 15;
int I4 = 16;
int I5 = 17;
int I6 = 18;
int I7 = 19;
int I8 = 20;
int I9 = 21;
int I10 = 2;
int I11 = 3;
int I12 = 4;
int I13 = 5;
int I14 = 6;int In8 = 0;
int In9 = 0;void setup() {
// put your setup code here, to run once:
pinMode(I1, INPUT_PULLUP);
pinMode(I2, INPUT_PULLUP);
pinMode(I3, INPUT_PULLUP);
pinMode(I4, INPUT_PULLUP);
pinMode(I5, INPUT_PULLUP);
pinMode(I6, INPUT_PULLUP);
pinMode(I7, INPUT_PULLUP);
pinMode(I8, INPUT_PULLUP);
pinMode(I9, INPUT_PULLUP);
pinMode(I10, INPUT_PULLUP);
pinMode(I11, INPUT_PULLUP);
pinMode(I12, INPUT_PULLUP);
pinMode(I13, INPUT_PULLUP);
pinMode(I14, INPUT_PULLUP);Serial.setTimeout(1);
Serial.begin(115200);}
void loop() {
delay(1);
if (Serial.available() > 0) {
incoming = Serial.readString();
incoming.toUpperCase();
incoming.trim();
}if (incoming == "READ" ) {
if (analogRead(I8) > 200) {
In8 = 1 ;
}
else {
In8 = 0 ;
}if (analogRead(I9) > 200) {
In9 = 1 ;
}
else {
In9 = 0 ;
}inputs = digitalRead(I1);
inputs = inputs + digitalRead(I2) + digitalRead(I3) + digitalRead(I4) + digitalRead(I5) + digitalRead(I6) + digitalRead(I7) + In8 + In9;
inputs = inputs + digitalRead(I10) + digitalRead(I11) + digitalRead(I12) + digitalRead(I13) + digitalRead(I14);
inputs.trim();
//Serial.begin(115200);
Serial.print("IN:");
Serial.println(inputs);}
incoming = "";
Serial.flush();
}