Blinky Arduino M0

arduino m0 samd21 robotdyn

Create a blinky LED with RobotDyn’s M0-Mini board which is compatible with Arduino firmware.

For serial printing, SerialUSB.println() should be used instead of Serial.println() because SerialUSB uses the Native Port, which is an emulated serial port (USB-CDC).

The following code should be used for initialising the serial so that the print statements can be viewed in the setup():

SerialUSB.begin(9600);
while (!SerialUSB) { }

Code

Download code
#define LED 13  // Pin 13 is connected to an on-board Blue LED

void setup() {
  pinMode(LED, OUTPUT);

  SerialUSB.begin(9600);
  while (!SerialUSB) { }
  delay(100);

  SerialUSB.println("Start!");
}

void loop() {
  SerialUSB.println("HIGH");
  digitalWrite(LED, HIGH);
  delay(500);

  SerialUSB.println("LOW");
  digitalWrite(LED, LOW);
  delay(500);
}

Serial console

Serial output from the firmware.

Blinky Arduino M0 serial console

References