Skip to main content

Arduino Code To Wire any Serial Device

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX ]] change this to pin to which arduino is connected

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }



  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Comments