Blinky Arduino M0

dev board RobotDyn M0 mini
firmware Arduino
chip SAMD21

Before starting

Dependancies

Ensure the following requirements are available:

Buy the components

Description

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) { }

Some errors on RobotDyn M0 mini board

  • Pins D2 (PA14) and D4 (PA08) are swapped
  • Pin D12 / MISO on ICSP header is PA12

Code

Download code
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

  SerialUSB.begin(9600);
  // Blinky will not start unless serial prints are enabled
  // while (!SerialUSB) { }
  delay(100);

  SerialUSB.println("Start!");
}

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

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

Makefile

BOARD?=arduino:samd:mzero_bl
PORT := $(shell ls /dev/cu.usbmodem*)

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD)

clean:
	rm -r build

Serial console

Serial output from the firmware.

Blinky Arduino M0 serial console

Arduino IDE settings

Ensure the following IDE settings before flashing.

Blinky Arduino M0 Arduino IDE settings

Prototype

A photo of the actual setup.

Blinky Arduino M0 prototype

References

Watch