Difference between revisions of "Arduino-USB-Serial-Communication"

From Digipool-Wiki
Jump to: navigation, search
(Created page with "<pre> void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { // check if data is available if (Serial.available() > 0) {...")
 
(No difference)

Latest revision as of 23:47, 5 February 2023

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
  // check if data is available
  if (Serial.available() > 0) {
    // read the incoming string:
    String incomingString = Serial.readStringUntil('\n');

    // prints the received data
    Serial.print("I received: ");
    Serial.println(incomingString);
  }
}