Built-in project · Seeed XIAO SAMD21

XIAO SAMD21 serial

Two ports at once: Serial on the chip’s own USB, and Serial1 on D6 and D7 with one jumper between them. The whole build, a Seeed XIAO SAMD21, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Runs in your browser. Free, and no account needed.

XIAO SAMD21 serial · Seeed XIAO SAMD21live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Seeed XIAO SAMD21
// Serial: the two ports this board has, and how they differ.
//
// `Serial` is the chip's own USB. It is what the serial monitor is connected
// to, and it has no baud rate of its own: the number below would be passed to
// the host, which is free to ignore it. There is no USB stack in the model, so
// `while (!Serial)` returns at once here; on a real XIAO it waits for the
// host to enumerate the device.
//
// `Serial1` is SERCOM4 on D6 (TX) and D7 (RX): real 8N1 frames on real pins.
// Wire a jumper from D6 to D7 and this sketch hears its own echo.

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);
  Serial.println("XIAO SAMD21 ready");
  Serial.println("type something and press enter");
  Serial1.println("and this goes out of D6 at 9600 baud");
}

void loop() {
  while (Serial.available()) {
    int c = Serial.read();

    Serial.print("you typed: ");
    Serial.println((char)c);
    Serial1.write((uint8_t)c);
  }
  while (Serial1.available()) {
    Serial.print("D7 heard: ");
    Serial.println((char)Serial1.read());
  }
  delay(20);
}

Parts list

1 part, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

1 connection, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Seeed XIAO SAMD21 pin D6; Seeed XIAO SAMD21 pin D7

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.