SemlerPDX icon

Hello-World_ArduinoConsoleApp_CompanionSketch

SemlerPDX | PRO | 07/06/22 08:05:09 PM UTC (Edited) | 0 ⭐ | 1204 👁️ | Never ⏰ | []
Arduino |

890 B

|

None

|

0 👍

/

0 👎

//This example Arduino Sketch is for use on Arduino Uno/Nano/Micro (or equiv. clone boards)
// -Problem of serial read timeout on Micro with USB CDC Serial hardware not present on Uno/Nano/Mini
// --complete details here: 
// https://github.com/SemlerPDX/ArduinoConsoleAppTest1
 
 
void WriteMethod_Characters(String dataToSend) {
  for (int i = 0; i <= dataToSend.length(); i++) {
    Serial.write(dataToSend.charAt(i));
  }
}
 
void setup() {
  Serial.begin(9600); // Define speed at 9600 baud
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB
  }
}
 
void loop() {
  String dataPrints = "";
  dataPrints.concat("[Hello,");
  dataPrints.concat(Serial.availableForWrite());
  dataPrints.concat(",World]");
  
  //This issue occurs regardless of print()/println()/write() methods
  WriteMethod_Characters(dataPrints);
  delay(1000);
  Serial.println();
}

Comments