I'm programming the arduino mega to control some motor controllers with serial outputs.
I was doing a test with Serial.print() function, but I have some problems with it.
My loop function:
speed1 is a int
for some reason, the serial monitor never shows what I type in.
for example, i type in 78, but the serial monitor either shows 55 or 10.
am I doing something wrong? I feel like that it is not receiving my commands as it is, but as an ASCII code.
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial test 0021"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
char c = Serial.read();
readString += c;}
}
if (readString.length() >0) {
Serial.println(readString);
readString="";
}
}